0

How can I get suggestions from a list while typing in a ttk.Combobox?

A little like google but the suggested words are in a list.

My code so far:

from tkinter import Tk, ttk, StringVar, OptionMenu

root = Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.geometry("%dx%d+0+0" % (w, h))


lst=["tip1","oop","ool2","oll3","tip2","ool1","some","tip3","ool","oop"]



t = ttk.Combobox(scrollable_frame, values=lst_matricula)
t.grid(row=0, column=0,sticky="w",padx=2,pady=2)



if __name__ == "__main__":
    root.mainloop()

First i need the optionMenu to be editable and then while i type it search the list for matches.

Been looking to binding events but there is no event onchange :s

Can anyone help me out?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
frepynow
  • 5
  • 3
  • It would have been better to have posted a short bit of code just building an options menu: nobody can *run* that because they don't have your buzzers.xlsx – 2e0byo Sep 24 '21 at 09:36
  • @2e0byo your right, please check the updated post again – frepynow Sep 24 '21 at 09:45
  • `OptionMenu` cannot be set to editable, use `ttk.Combobox` instead. – acw1668 Sep 24 '21 at 09:54
  • @acw1668 thanks, your right. now how can i bind it to check for the match in the list? – frepynow Sep 24 '21 at 10:07
  • Refer [this](https://stackoverflow.com/a/12298622/5317403) or [AutocompleteCombobox](https://github.com/TkinterEP/ttkwidgets/blob/master/ttkwidgets/autocomplete/autocompletecombobox.py) from `ttkwidgets` module. – acw1668 Sep 24 '21 at 10:11
  • Does this answer your question? [Tkinter - How to create a combo box with autocompletion](https://stackoverflow.com/questions/12298159/tkinter-how-to-create-a-combo-box-with-autocompletion) – Sylvester Kruin Sep 24 '21 at 18:51

0 Answers0