Tkinter Wiki   TreeExplorer UserPreferences
 
HelpContents FindPage Diffs Info Edit Subscribe XML Print View

TreeExplorer: For exploring the contents of a tree data structure.

Code: (excerpt of treexplorer.py)

  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 
 30 
 31 
 32 
 33 
 34 
 35 
 36 
    class TETest(GuiAppD.GuiAppD):
        appname = 'Test the TreeExplorer widget'

        def createInterface(self):
            data = NavigableTree.create_from_tuples(
                ('data', 'this is the data node',
                        [ ('sub1', 'this is sub1 node',
                                  [ ('sub11', 'This is sub11 node', [])
                                  ]
                           ),
                           ('sub2', 'this is sub2 node',
                                  [ ('sub21', 'this is sub21 node',
                                            [ ('sub211', 'this is sub211 node', [])
                                            ]
                                    ),
                                    ('sub22', 'this is sub22 node', [] ),
                                    ('sub23', 'this is sub23 node', [] ),
                                  ]
                           ),
                           ('sub3', 'this is sub3 node', []),
                         ]
                )
            )
            self.explorer = SimpleTreeExplorer(
                self.interior(),
                labelpos = 'n',
                label_text='TreeExplorer',
                height=200,
                )
            self.explorer.pack(side=Tkinter.TOP,
                          expand=Tkinter.YES,
                          fill=Tkinter.BOTH)
            self.explorer.component('navigator').configure(treedata=data)


    TETest().run()

Screenshot:

TreeExplorer1.png

PythonPowered