When I check a checkbox in Tkinter the value of checkbox gets vanished.
This problem appears in Linux only.
The same code I am using in windows and it is working Fine.
I Referred this link to make this gui
How to create a tree view with checkboxes in Python
Code:
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()
Before check :
After check :
As you can see in the image that checkbox Test
disappears after click on Test.This problem is happening only in Linux.Can anyone Give me any Solution ?
I got the solution.Actually the colour of background and foreground was same.therefore i changed the colour of foreground and background.
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()