Your code is close but not enough information given. I have done some modifications to make sure the set-up is done correctly. I have also added dummy data as items to test.
You will need both the 'tkinter' and 'ttk' modules -
import tkinter as tk
from tkinter import ttk
class ItemSearchApp:
def __init__(self, root):
self.root = root
self.root.title("Item Search Engine")
self.treeview_almacen = ttk.Treeview(root, columns=("item_name"))
self.treeview_almacen.heading("item_name", text="Item Name")
self.treeview_almacen.pack()
self.entry_buscador = ttk.Entry(root)
self.entry_buscador.pack()
self.entry_buscador.bind("<KeyRelease>", self.buscar)
self.populate_treeview()
def populate_treeview(self):
items = ["Apple", "Banana", "Orange", "Pear", "Grapes", "Pineapple"]
for item in items:
self.treeview_almacen.insert("", "end", values=(item))
def buscar(self, event):
self.query = self.entry_buscador.get().lower()
for item in self.treeview_almacen.get_children():
values = self.treeview_almacen.item(item, "values")
if self.query in values[0].lower():
self.treeview_almacen.selection_set(item)
self.treeview_almacen.focus(item)
self.treeview_almacen.see(item)
else:
self.treeview_almacen.selection_remove(item)
root = tk.Tk()
app = ItemSearchApp(root)
root.mainloop()
And voila, this should work for you.