Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- window_hint = None
- Heading = ['Наименование', 'Мярка', 'Количество']
- EntryData = [('', 'кг', 5000),
- ('', 'бр', 5000),
- ('', 'л', 5000),
- ('', 'пак', 5000),
- ]
- def show_hint(event):
- pass
- global window_hint
- if window_hint is None:
- window_hint = Toplevel(entry1) # Закачаме прозореца на подсказката към Entry
- x_entry1 = entry1.winfo_rootx()
- y_entry1 = entry1.winfo_rooty()
- x = x_entry1
- y = y_entry1 + entry1.winfo_height() + 1 # височината на entry1 + 1 пиксел (под полето)
- window_hint.wm_overrideredirect(True) # Да не се появява заглавието на прозореца
- window_hint.wm_geometry("+%d+%d" % (x, y))
- window_hint.attributes('-topmost', 'true')
- # Create Treeview
- treev = ttk.Treeview(window_hint, show='headings', columns=tuple([str(i) for i in range(1, 4)]), selectmode='extended')
- for i in range(len(Heading)):
- treev.heading(str(i+1), text=Heading[i])
- treev.column(str(i+1))
- treev.pack()
- # for j in range(len(EntryData)):
- # data = EntryData[j]
- # stock = Label(treev, text=str(j+1), width=6).grid(row=j+1, column=0)
- # msr = Label(treev, text=data[1], width=4).grid(row=j+1, column=1)
- # qty = Label(treev, text=data[2], width=4).grid(row=j+1, column=2)
- input_text = entry1.get()
- length = len(str(input_text).strip())
- if length <= 0:
- window_hint.destroy()
- window_hint = None
- # data source list,
- my_list = ['aecde', 'adba', 'acbd', 'abcd', 'abded',
- 'bdbd', 'baba', 'bcbc', 'bdbd']
- # Main window
- root = Tk()
- root.geometry("410x400") # Size of the window
- root.title("Autocomplete") # Adding a title
- font1 = ('Times', 24, 'bold') # font size and style
- # Създаване на Entry
- ent_text = StringVar # За да може да ползваме текста в Entry за по-нататъшна обработка
- entry1 = Entry(root, textvariable=ent_text, width=40, bd=3)
- entry1.bind('<KeyRelease>', show_hint) # При пускане на клавиша
- entry1.pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement