From 579c608e3e9bfa8915f2738767073e2e54f3c3fe Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 26 Mar 2007 19:55:31 +0000 Subject: [PATCH] 0.9.1 of TreeMixin git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45075 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/TreeMixin.py | 8 ++++++-- wxPython/docs/CHANGES.txt | 2 +- wxPython/tests/TreeMixinTest.py | 32 ++++++++++++++++++++++++++++- wxPython/wx/lib/mixins/treemixin.py | 8 ++++---- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/wxPython/demo/TreeMixin.py b/wxPython/demo/TreeMixin.py index 145370a4bf..8a3245571b 100644 --- a/wxPython/demo/TreeMixin.py +++ b/wxPython/demo/TreeMixin.py @@ -1,6 +1,10 @@ import wx, wx.lib.customtreectrl, wx.gizmos -from wx.lib.mixins import treemixin +try: + import treemixin +except ImportError: + from wx.lib.mixins import treemixin +overview = treemixin.__doc__ class TreeModel(object): ''' TreeModel holds the domain objects that are shown in the different @@ -104,7 +108,7 @@ class DemoTreeMixin(treemixin.VirtualTree, treemixin.DragAndDrop, return 1 def OnDrop(self, dropTarget, dragItem): - dropIndex = self.GetIndoxOfItem(dropTarget) + dropIndex = self.GetIndexOfItem(dropTarget) dropText = self.model.GetText(dropIndex) dragIndex = self.GetIndexOfItem(dragItem) dragText = self.model.GetText(dragIndex) diff --git a/wxPython/docs/CHANGES.txt b/wxPython/docs/CHANGES.txt index bd7ef1ba07..72ead3ef8d 100644 --- a/wxPython/docs/CHANGES.txt +++ b/wxPython/docs/CHANGES.txt @@ -7,7 +7,7 @@ Recent Changes for wxPython wxGTK: Make wx.NO_BORDER style work with wx.RadioBox (patch 1525406) -Update to 0.9 of TreeMixin. +Update to 0.9.1 of TreeMixin. diff --git a/wxPython/tests/TreeMixinTest.py b/wxPython/tests/TreeMixinTest.py index a967b80568..55a740ae67 100644 --- a/wxPython/tests/TreeMixinTest.py +++ b/wxPython/tests/TreeMixinTest.py @@ -1,5 +1,8 @@ import wx, wx.gizmos, wx.lib.customtreectrl, unittest -from wx.lib.mixins import treemixin +try: + import treemixin +except ImportError: + from wx.lib.mixins import treemixin # VirtualTree tests @@ -721,6 +724,33 @@ class VanillaCustomTreeCtrlTestCase(VanillaTreeCommonTests, TreeClass = wx.lib.customtreectrl.CustomTreeCtrl +# Tests of the tree controls without any mixin, to document behaviour +# that is either different between tree control widgets or undesired +# behaviour. + +class TreeCtrlTestCase(unittest.TestCase): + def setUp(self): + self.frame = wx.Frame(None) + self.tree = wx.TreeCtrl(self.frame, style=wx.TR_HIDE_ROOT) + + def testSelectHiddenRootItem(self): + root = self.tree.AddRoot('Hidden root') + self.tree.SelectItem(root) + self.assertEqual(root, self.tree.GetSelection()) + + +class CustomTreeCtrlTestCase(unittest.TestCase): + def setUp(self): + self.frame = wx.Frame(None) + self.tree = wx.lib.customtreectrl.CustomTreeCtrl(self.frame, + style=wx.TR_HIDE_ROOT) + + def testSelectHiddenRootItem(self): + root = self.tree.AddRoot('Hidden root') + self.tree.SelectItem(root) + self.assertEqual(root, self.tree.GetSelection()) + + if __name__ == '__main__': app = wx.App(False) unittest.main() diff --git a/wxPython/wx/lib/mixins/treemixin.py b/wxPython/wx/lib/mixins/treemixin.py index 996101c5de..f3a840708f 100644 --- a/wxPython/wx/lib/mixins/treemixin.py +++ b/wxPython/wx/lib/mixins/treemixin.py @@ -25,8 +25,8 @@ The VirtualTree and DragAndDrop mixins force the wx.TR_HIDE_ROOT style. Author: Frank Niessink License: wxWidgets license -Version: 0.9 -Date: 18 March 2007 +Version: 0.9.1 +Date: 26 March 2007 ExpansionState is based on code and ideas from Karsten Hilbert. Andrea Gavana provided help with the CustomTreeCtrl integration. @@ -148,7 +148,7 @@ class TreeAPIHarmonizer(object): else: selections = [] # If the root item is hidden, it should never be selected, - # unfortunately, CustomTreeCtrl allows it to be selected. + # unfortunately, CustomTreeCtrl and TreeCtrl allow it to be selected. if self.HasFlag(wx.TR_HIDE_ROOT): rootItem = self.GetRootItem() if rootItem and rootItem in selections: @@ -197,7 +197,7 @@ class TreeAPIHarmonizer(object): super(TreeAPIHarmonizer, self).ExpandAll(item) def ExpandAllChildren(self, item): - # TreeListCtrl and CustomTreeCtrl don't have ExpandallChildren + # TreeListCtrl doesn't have ExpandallChildren try: super(TreeAPIHarmonizer, self).ExpandAllChildren(item) except AttributeError: