How to clear text field part of ttk.Combobox?

Marek picture Marek · Feb 5, 2016 · Viewed 9.8k times · Source

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.

Answer

All Workers Are Essential picture All Workers Are Essential · Feb 6, 2016

You can clear the selected value of a Combobox by setting its value to an empty string:

ComboBox.set('')