如何清除ttk.Combobox的文本字段部分? [英] How to clear text field part of ttk.Combobox?

查看:150
本文介绍了如何清除ttk.Combobox的文本字段部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个删除功能,应该删除组合框中的所选项目及其关联的字典值。然后应该清除显示该字典值的文本框,而我希望它也清除组合框的文本文件。有没有办法做到?

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.

推荐答案

您可以清除选中的内容将组合框的值设置为空字符串:

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

ComboBox.set('')

这篇关于如何清除ttk.Combobox的文本字段部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆