new VC++ project files with both dll and lib in one project
[wxWidgets.git] / wxPython / demo / pyTree.py
index 47283527f113682690a5eef78742a88f28e23ea2..72cb2ff31777422ae599d04ef53e2303981f8c3c 100644 (file)
@@ -24,7 +24,7 @@ beautifully documented...
 """
 
 from wxPython import wx
 """
 
 from wxPython import wx
-import string # Don't use it, but it's fun expanding :-)
+import sys, string # Don't use it, but it's fun expanding :-)
 
 #----------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------
 
@@ -78,11 +78,12 @@ class pyTree(wx.wxTreeCtrl):
         wx.wxTreeCtrl.__init__(self, parent, id)
         self.root = self.AddRoot(str(root), -1, -1, wx.wxTreeItemData(root))
         if dir(root):
         wx.wxTreeCtrl.__init__(self, parent, id)
         self.root = self.AddRoot(str(root), -1, -1, wx.wxTreeItemData(root))
         if dir(root):
-            self.SetItemHasChildren(self.root, wx.TRUE)
+            self.SetItemHasChildren(self.root, wx.True)
         wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding)
         wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemCollapsed)
         wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
         self.output = None
         wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding)
         wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemCollapsed)
         wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
         self.output = None
+        self.Expand(self.root)
 
 
     def SetOutput(self, output):
 
 
     def SetOutput(self, output):
@@ -111,6 +112,8 @@ class pyTree(wx.wxTreeCtrl):
         will again figure out what the offspring is.
         """
         item = event.GetItem()
         will again figure out what the offspring is.
         """
         item = event.GetItem()
+        if self.IsExpanded(item):  # This event can happen twice in the self.Expand call
+            return
         obj = self.GetPyData( item )
         lst = dir(obj)
         for key in lst:
         obj = self.GetPyData( item )
         lst = dir(obj)
         for key in lst:
@@ -118,7 +121,7 @@ class pyTree(wx.wxTreeCtrl):
             new_item = self.AppendItem( item, key, -1, -1,
                                         wx.wxTreeItemData(new_obj) )
             if dir(new_obj):
             new_item = self.AppendItem( item, key, -1, -1,
                                         wx.wxTreeItemData(new_obj) )
             if dir(new_obj):
-                self.SetItemHasChildren(new_item, wx.TRUE)
+                self.SetItemHasChildren(new_item, wx.True)
 
     def OnItemCollapsed(self, event):
         """
 
     def OnItemCollapsed(self, event):
         """
@@ -161,7 +164,8 @@ def runTest(frame, nb, log):
     This method is used by the wxPython Demo Framework for integrating
     this demo with the rest.
     """
     This method is used by the wxPython Demo Framework for integrating
     this demo with the rest.
     """
-    thisModule = __import__(__name__, globals())
+    #thisModule = __import__(__name__, globals())
+    thisModule = sys.modules[__name__]
     win = wx.wxFrame(frame, -1, "PyTreeItemData Test")
     split = wx.wxSplitterWindow(win, -1)
     tree = pyTree(split, -1, thisModule)
     win = wx.wxFrame(frame, -1, "PyTreeItemData Test")
     split = wx.wxSplitterWindow(win, -1)
     tree = pyTree(split, -1, thisModule)
@@ -185,7 +189,7 @@ if __name__ == '__main__':
         def __init__(self):
             """Make a splitter window; left a tree, right a textctrl. Wow."""
             import __main__
         def __init__(self):
             """Make a splitter window; left a tree, right a textctrl. Wow."""
             import __main__
-            wx.wxFrame.__init__(self, wx.NULL, -1, "PyTreeItemData Test",
+            wx.wxFrame.__init__(self, None, -1, "PyTreeItemData Test",
                                 wx.wxDefaultPosition, wx.wxSize(800,500))
             split = wx.wxSplitterWindow(self, -1)
             tree = pyTree(split, -1, __main__)
                                 wx.wxDefaultPosition, wx.wxSize(800,500))
             split = wx.wxSplitterWindow(self, -1)
             tree = pyTree(split, -1, __main__)
@@ -201,9 +205,9 @@ if __name__ == '__main__':
         def OnInit(self):
             """OnInit. Boring, boring, boring!"""
             frame = MyFrame()
         def OnInit(self):
             """OnInit. Boring, boring, boring!"""
             frame = MyFrame()
-            frame.Show(wx.TRUE)
+            frame.Show(wx.True)
             self.SetTopWindow(frame)
             self.SetTopWindow(frame)
-            return wx.TRUE
+            return wx.True
 
     app = MyApp(0)
     app.MainLoop()
 
     app = MyApp(0)
     app.MainLoop()