【发布时间】:2017-12-13 10:14:04
【问题描述】:
当我在 Tkinter 中选中一个复选框时,复选框的值消失了。
此问题仅出现在 Linux 中。
我在 Windows 中使用的相同代码,它运行良好。
我参考了这个链接来制作这个 gui
How to create a tree view with checkboxes in Python
代码:
import Tkinter as tk
import Tix as tix
def selectItem(item):
if cl.getstatus(item) == 'on':
print("Checked")
if cl.getstatus(item) == 'off':
print("Unchecked")
root = tix.Tk()
cl = tix.CheckList(root,browsecmd=selectItem)
cl.pack()
cl.hlist.add("CL1", text="Test")
cl.setstatus("CL1","off")
cl.hlist.add("CL1.Item1", text="child")
cl.setstatus("CL1.Item1","off")
root.mainloop()
检查前:
检查后:
正如您在图像中看到的那样,复选框 Test 在单击测试后消失。此问题仅在 Linux 中发生。谁能给我任何解决方案?
【问题讨论】:
标签: python checkbox tkinter tix