]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/wxTreeCtrl.py
Added SetOrderByColNums() function
[wxWidgets.git] / wxPython / demo / wxTreeCtrl.py
index 9f1c20183a67538a8779f3cbc89f27343c82c60f..64f8662fd46b3e03087cb355717de7c5ad0bb7b2 100644 (file)
@@ -21,7 +21,8 @@ class MyTreeCtrl(wxTreeCtrl):
 
 class TestTreeCtrlPanel(wxPanel):
     def __init__(self, parent, log):
-        wxPanel.__init__(self, parent, -1)
+        # Use the WANTS_CHARS style so the panel doesn't eat the Return key.
+        wxPanel.__init__(self, parent, -1, style=wxWANTS_CHARS)
         EVT_SIZE(self, self.OnSize)
 
         self.log = log
@@ -68,6 +69,7 @@ class TestTreeCtrlPanel(wxPanel):
         EVT_TREE_SEL_CHANGED    (self, tID, self.OnSelChanged)
         EVT_TREE_BEGIN_LABEL_EDIT(self, tID, self.OnBeginEdit)
         EVT_TREE_END_LABEL_EDIT (self, tID, self.OnEndEdit)
+        EVT_TREE_ITEM_ACTIVATED (self, tID, self.OnActivate)
 
         EVT_LEFT_DCLICK(self.tree, self.OnLeftDClick)
         EVT_RIGHT_DOWN(self.tree, self.OnRightClick)
@@ -135,9 +137,16 @@ class TestTreeCtrlPanel(wxPanel):
     def OnSelChanged(self, event):
         self.item = event.GetItem()
         self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(self.item))
-        self.log.WriteText("BoundingRect: %s\n" %
-                           self.tree.GetBoundingRect(self.item, true))
+        if wxPlatform == '__WXMSW__':
+            self.log.WriteText("BoundingRect: %s\n" %
+                               self.tree.GetBoundingRect(self.item, true))
+        #items = self.tree.GetSelections()
+        #print map(self.tree.GetItemText, items)
+        event.Skip()
+
 
+    def OnActivate(self, evt):
+        self.log.WriteText("OnActivate: %s\n" % self.tree.GetItemText(self.item))
 
 
 #---------------------------------------------------------------------------
@@ -160,11 +169,6 @@ def runTest(frame, nb, log):
 
 
 
-
-
-
-
-
 overview = """\
 A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wxTreeItemId handles.