当我在 Tkinter 中选中复选框时,值消失了

Value gets vanished when i check a checkbox in Tkinter

当我在 Tkinter 中选中复选框时,复选框的值消失了。

此问题仅在 Linux 中出现。

我在 windows 中使用的相同代码并且工作正常。

我参考了这个 link 来制作这个 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.This 后复选框 Test 消失了 问题只发生在 Linux.Can 任何人给我任何解决方案?

我得到 solution.Actually 背景和前景的颜色是 same.therefore 我改变了前景和背景的颜色。

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.hlist.config(bg='White',bd=0,selectmode='none',selectbackground='white',selectforeground='black',drawbranch=True)
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()