tkinter - How to create a tree view with checkboxes in Python -
i've been using tkinter , tix write small program. i'm @ point need tree view checkboxes (checkbuttons) can select items tree view. there easy way this? i've been looking @ ttk.treeview () , looks easy tree view there way insert checkbutton view?
a simple code snippet appreciated.
i'm not limited ttk. do; long have example or docs can make work
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="checklist1") self.cl.hlist.add("cl1.item1", text="subitem1") self.cl.hlist.add("cl2", text="checklist2") self.cl.hlist.add("cl2.item1", text="subitem1") 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()
Comments
Post a Comment