i can get status of checkbox but How to Get value of checkbox in Tix
.
from tkinter import tix
class View(object):
def __init__(self, root):
self.root = root
self.makeCheckList()
def makeCheckList(self):
self.cl = tix.CheckList(self.root, browsecmd=self.selectItem)
self.cl.pack()
self.cl.hlist.add("CL1", text="C:/")
self.cl.hlist.add("CL1.Item1", text="subitem1")
self.cl.hlist.add("CL2", text="some folder")
self.cl.hlist.add("CL2.Item1", text="test")
self.cl.setstatus("CL2", "on")
self.cl.setstatus("CL2.Item1", "on")
self.cl.setstatus("CL1", "off")
self.cl.setstatus("CL1.Item1", "off")
self.cl.autosetmode()
def selectItem(self, item):
print (item, self.cl.getstatus(item))
def main():
root = tix.Tk()
view = View(root)
root.update()
root.mainloop()
if __name__ == '__main__':
main()
Expected output
if i click on checkbox c:/
then it should print c:/
.I want the value of checkbox.
Output
It keeps all in hlist
Official documentation for more informations about hlist
sends to tcl/tk documentation and then you can find
pathName item_cget entryPath col option
But it doesn't work as I expected
value = self.cl.hlist.item_cget('CL1.Item1', 0, 'text')
# _tkinter.TclError: unknown option "text"
You have to use "-text"
instead of "text"
value = self.cl.hlist.item_cget('CL1.Item1', 0, '-text')