问题
I have a delete function that is supposed to remove the selected item in the Combobox and its associated dictionary value. Then it is supposed to clear the textbox that displays that dictionary value and I would like it to also clear just the text file of the combo box. Is there a way to do that?
def DeleteEntry():
if not ComboBox.get() == "" and ComboBox.get() in FriendMap:
del FriendMap[ComboBox.get()]
FriendListKeys = FriendMap.keys()
FriendListKeys.sort()
ComboBox['values']=FriendListKeys
FriendListBox.delete(1.0,2.0)
That is what I have thus far but I would like the next line to delete the text field in the Combobox.
回答1:
You can clear the selected value of a Combobox by setting its value to an empty string:
ComboBox.set('')
来源:https://stackoverflow.com/questions/35233043/how-to-clear-text-field-part-of-ttk-combobox