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
This commit is contained in:
Robin Dunn
2007-03-26 19:55:31 +00:00
parent bb7882b5d1
commit 579c608e3e
4 changed files with 42 additions and 8 deletions

View File

@@ -1,6 +1,10 @@
import wx, wx.lib.customtreectrl, wx.gizmos import wx, wx.lib.customtreectrl, wx.gizmos
try:
import treemixin
except ImportError:
from wx.lib.mixins import treemixin from wx.lib.mixins import treemixin
overview = treemixin.__doc__
class TreeModel(object): class TreeModel(object):
''' TreeModel holds the domain objects that are shown in the different ''' TreeModel holds the domain objects that are shown in the different
@@ -104,7 +108,7 @@ class DemoTreeMixin(treemixin.VirtualTree, treemixin.DragAndDrop,
return 1 return 1
def OnDrop(self, dropTarget, dragItem): def OnDrop(self, dropTarget, dragItem):
dropIndex = self.GetIndoxOfItem(dropTarget) dropIndex = self.GetIndexOfItem(dropTarget)
dropText = self.model.GetText(dropIndex) dropText = self.model.GetText(dropIndex)
dragIndex = self.GetIndexOfItem(dragItem) dragIndex = self.GetIndexOfItem(dragItem)
dragText = self.model.GetText(dragIndex) dragText = self.model.GetText(dragIndex)

View File

@@ -7,7 +7,7 @@ Recent Changes for wxPython
wxGTK: Make wx.NO_BORDER style work with wx.RadioBox (patch 1525406) 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.

View File

@@ -1,4 +1,7 @@
import wx, wx.gizmos, wx.lib.customtreectrl, unittest import wx, wx.gizmos, wx.lib.customtreectrl, unittest
try:
import treemixin
except ImportError:
from wx.lib.mixins import treemixin from wx.lib.mixins import treemixin
@@ -721,6 +724,33 @@ class VanillaCustomTreeCtrlTestCase(VanillaTreeCommonTests,
TreeClass = wx.lib.customtreectrl.CustomTreeCtrl 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__': if __name__ == '__main__':
app = wx.App(False) app = wx.App(False)
unittest.main() unittest.main()

View File

@@ -25,8 +25,8 @@ The VirtualTree and DragAndDrop mixins force the wx.TR_HIDE_ROOT style.
Author: Frank Niessink <frank@niessink.com> Author: Frank Niessink <frank@niessink.com>
License: wxWidgets license License: wxWidgets license
Version: 0.9 Version: 0.9.1
Date: 18 March 2007 Date: 26 March 2007
ExpansionState is based on code and ideas from Karsten Hilbert. ExpansionState is based on code and ideas from Karsten Hilbert.
Andrea Gavana provided help with the CustomTreeCtrl integration. Andrea Gavana provided help with the CustomTreeCtrl integration.
@@ -148,7 +148,7 @@ class TreeAPIHarmonizer(object):
else: else:
selections = [] selections = []
# If the root item is hidden, it should never be selected, # 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): if self.HasFlag(wx.TR_HIDE_ROOT):
rootItem = self.GetRootItem() rootItem = self.GetRootItem()
if rootItem and rootItem in selections: if rootItem and rootItem in selections:
@@ -197,7 +197,7 @@ class TreeAPIHarmonizer(object):
super(TreeAPIHarmonizer, self).ExpandAll(item) super(TreeAPIHarmonizer, self).ExpandAll(item)
def ExpandAllChildren(self, item): def ExpandAllChildren(self, item):
# TreeListCtrl and CustomTreeCtrl don't have ExpandallChildren # TreeListCtrl doesn't have ExpandallChildren
try: try:
super(TreeAPIHarmonizer, self).ExpandAllChildren(item) super(TreeAPIHarmonizer, self).ExpandAllChildren(item)
except AttributeError: except AttributeError: