I'm using multiple comboboxes in tkinter, I've passed a list of values to each box.
Currently, after you choose an option you can't clear that box, some selection remains
I want to be able to clear all boxes or have a "blank" value if you want to unselect a box.
So far I've tried assigning a separate button to clear the whole selection but I get errors. The button is assigned this command:
for c in categories:
ttk.Label(text=c, relief=tk.RIDGE, width=15).grid(row=r,column=0)
categoriesParts = ttk.Combobox(root, textvariable = listVariables[r], values=listMakers[r],width=10, state="readonly")
categoriesParts.grid(row=r,column=1)
r = r + 1
def clearComboBox():
categoriesParts.delete(0, END)
browseButton_Clear = tk.Button(text='Clear Config', command=clearComboBox, bg='green', fg='white')
I get errors saying: AttributeError: module 'tkinter.ttk' has no attribute 'tk'
EDIT: working code, if anyone needs:
list_of_widgets = []
for c in categories:
ttk.Label(text=c, relief=tk.RIDGE, width=15).grid(row=r,column=0)
categoriesParts = ttk.Combobox(root, textvariable = listVariables[r], values=listMakers[r], width=10, state="readonly")
categoriesParts.grid(row=r,column=1)
list_of_widgets.append(categoriesParts)
r = r + 1
def clearComboBox():
for widget in list_of_widgets:
widget.set('')
browseButton_Clear = tk.Button(text='Clear Config', command=clearComboBox, bg='green', fg='white')