Python 如何在tix中获取复选框的值

Python 如何在tix中获取复选框的值,python,user-interface,tkinter,tix,Python,User Interface,Tkinter,Tix,我可以获取复选框的状态,但如何在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.selec

我可以获取复选框的状态,但如何在
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()     
预期产出

如果我点击checkbox
c://
,那么它应该打印
c://
。我想要checkbox的值

输出


它将所有内容都保存在
hlist

有关
hlist
的更多信息,请发送至,然后您可以找到

pathName item_cget entryPath col option
但它没有像我预期的那样工作

value = self.cl.hlist.item_cget('CL1.Item1', 0, 'text')

# _tkinter.TclError: unknown option "text"
您必须使用
“-text”
而不是
“text”


如何找到父路径?(路径名信息父入口路径)。这是在文件中给出的,但我找不到任何有用的解释。您能告诉我如何找到父路径吗?doc用tcl/tk语言显示代码。在您的代码中,
pathName
表示
self.cl.hist
entryPath
表示
CLI1
CLI1.Item1
,等等。
parent
可能表示
self.root
self.cl.hlist.info(self.root,'CL1')是否正确?我检查了文档,发现
parent
是粗体的-这意味着它将是python中的函数
info\u parent()
`
parent\u id=self.cl.hlist.info\u parent('CL1')
BTW:try
help(self.cl.hlist)
在代码中,它将显示所有函数-有时带有说明。
value = self.cl.hlist.item_cget('CL1.Item1', 0, '-text')