How to clear text field part of ttk.Combobox?

隐身守侯 提交于 2020-05-12 02:45:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!