Reputation: 2005
Hej, I want to produce an entry field (for directory paths) that also has the dropdown ability of an optionmenu (stating the 5 last used directories). It is basically supposed to look like the solution MATLAB uses. How do I go about that? I need the ability to manually change the path, so a plain optionmenu with a browse button won t do. Is there anything like that out there?
Upvotes: 1
Views: 1691
Reputation: 136
Use ttk.Combobox widget, http://www.tkdocs.com/tutorial/widgets.html#combobox (or http://www.tcl.tk/man/tcl/TkCmd/ttk_combobox.htm). Using this you can set default values, but you are also able to write in the entry a new value.
combobox = ttk.Combobox(parent)
combobox['values'] = five_last_dirs_tuple
combobox['state'] = 'normal'
# later...
path = combobox.get()
Hope this helps
Upvotes: 2