Reg:Getting text value of checkbox

Post here if you need help with creating a Graphical User Interface in Python.

Reg:Getting text value of checkbox

Postby Vibha » Thu Sep 19, 2013 3:33 pm

Hi,

Below is the code for creation of tree view with checkbox dynamically based on path of file given but i am facing problem in reading the text(that is the list of files in a directory) next to checkbox when checkbox is checked in..
Can anyone help me in reading the text next to checkbox?


Code: Select all
import Tix,os
 
class View(object):
   def __init__(self, root,path):
       self.root = root
       self.makeCheckList(path)
 
   def makeCheckList(self,path):
       self.cl = Tix.CheckList(self.root,browsecmd=self.selectItem)
       self.cl.pack()
       abspath = os.path.abspath(path)
       root_node = self.cl.hlist.add("CL1", text=abspath)
       self.process_directory(root_node, abspath)
       self.cl.setstatus("CL1", "off")
       self.cl.autosetmode()
 
   def process_directory(self, parent, path):
       i = 1
       for p in os.listdir(path):
           abspath = os.path.join(path, p)     
           isdir = os.path.isdir(abspath)
           oid = self.cl.hlist.add(parent+".Item"+str(i), text=p)
           self.cl.setstatus(parent+".Item"+str(i), "off")
           i = i + 1
           if isdir:
               self.process_directory(oid, abspath)
   def selectItem(self, item):
       print item, self.cl.getstatus(item)
 
def main():
   root = Tix.Tk()
   project_path = "path of file"//Give the path
   view = View(root,path=project_path)
   root.update()
   root.mainloop()
 
if __name__ == '__main__':
   main()
Last edited by stranac on Thu Sep 19, 2013 3:55 pm, edited 1 time in total.
Reason: Added code tags, locked post
Vibha
 
Posts: 2
Joined: Thu Sep 19, 2013 3:26 pm

Return to GUI

Who is online

Users browsing this forum: No registered users and 2 guests

cron