]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/lib/mvctree.py
Fix or add some DoGetBestSize's
[wxWidgets.git] / wxPython / wx / lib / mvctree.py
index cdf05f7ada983f16a588baf2eb839b88b10ea649..6a9a9bf3efc0954177be84a209c1fd186092cc4b 100644 (file)
@@ -1,11 +1,24 @@
+# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o 2.5 compatability update.
+# o I'm a little nervous about some of it though.
+#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxTreeModel -> TreeModel
+# o wxMVCTree -> MVCTree
+# o wxMVCTreeEvent -> MVCTreeEvent
+# o wxMVCTreeNotifyEvent -> MVCTreeNotifyEvent
+#
+
 """
 """
-wxMVCTree is a control which handles hierarchical data. It is constructed
+MVCTree is a control which handles hierarchical data. It is constructed
 in model-view-controller architecture, so the display of that data, and
 the content of the data can be changed greatly without affecting the other parts.
 
 in model-view-controller architecture, so the display of that data, and
 the content of the data can be changed greatly without affecting the other parts.
 
-wxMVCTree actually is even more configurable than MVC normally implies, because
+MVCTree actually is even more configurable than MVC normally implies, because
 almost every aspect of it is pluggable:
 almost every aspect of it is pluggable:
-    wxMVCTree - Overall controller, and the window that actually gets placed
+    MVCTree - Overall controller, and the window that actually gets placed
     in the GUI.
         Painter - Paints the control. The 'view' part of MVC.
            NodePainter - Paints just the nodes
     in the GUI.
         Painter - Paints the control. The 'view' part of MVC.
            NodePainter - Paints just the nodes
@@ -27,13 +40,31 @@ NOTE: This module is *not* supported in any way.  Use it however you
 """
 
 #------------------------------------------------------------------------
 """
 
 #------------------------------------------------------------------------
-from wxPython.wx import *
-import os, sys, traceback
+import  os
+import  sys
+import  traceback
+import  warnings
+
+import  wx
+#------------------------------------------------------------------------
+
+warningmsg = r"""\
+
+################################################\
+# This module is not supported in any way!      |
+#                                               |
+# See cource code for wx.lib.mvctree for more   |
+# information.                                  |
+################################################/
+
+"""
+
+warnings.warn(warningmsg, DeprecationWarning, stacklevel=2)
 #------------------------------------------------------------------------
 
 class MVCTreeNode:
     """
 #------------------------------------------------------------------------
 
 class MVCTreeNode:
     """
-    Used internally by wxMVCTree to manage its data. Contains information about
+    Used internally by MVCTree to manage its data. Contains information about
     screen placement, the actual data associated with it, and more. These are
     the nodes passed to all the other helper parts to do their work with.
     """
     screen placement, the actual data associated with it, and more. These are
     the nodes passed to all the other helper parts to do their work with.
     """
@@ -127,16 +158,16 @@ class Transform:
 
 class Painter:
     """
 
 class Painter:
     """
-    This is the interface that wxMVCTree expects from painters. All painters should
+    This is the interface that MVCTree expects from painters. All painters should
     be Painter subclasses.
     """
     def __init__(self, tree):
         self.tree = tree
     be Painter subclasses.
     """
     def __init__(self, tree):
         self.tree = tree
-        self.textcolor = wxNamedColour("BLACK")
-        self.bgcolor = wxNamedColour("WHITE")
-        self.fgcolor = wxNamedColour("BLUE")
-        self.linecolor = wxNamedColour("GREY")
-        self.font = wxFont(9, wxDEFAULT, wxNORMAL, wxNORMAL, False)
+        self.textcolor = wx.NamedColour("BLACK")
+        self.bgcolor = wx.NamedColour("WHITE")
+        self.fgcolor = wx.NamedColour("BLUE")
+        self.linecolor = wx.NamedColour("GREY")
+        self.font = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)
         self.bmp = None
 
     def GetFont(self):
         self.bmp = None
 
     def GetFont(self):
@@ -155,26 +186,26 @@ class Painter:
         return self.textcolor
     def SetTextColour(self, color):
         self.textcolor = color
         return self.textcolor
     def SetTextColour(self, color):
         self.textcolor = color
-        self.textbrush = wxBrush(color)
-        self.textpen = wxPen(color, 1, wxSOLID)
+        self.textbrush = wx.Brush(color)
+        self.textpen = wx.Pen(color, 1, wx.SOLID)
     def GetBackgroundColour(self):
         return self.bgcolor
     def SetBackgroundColour(self, color):
         self.bgcolor = color
     def GetBackgroundColour(self):
         return self.bgcolor
     def SetBackgroundColour(self, color):
         self.bgcolor = color
-        self.bgbrush = wxBrush(color)
-        self.bgpen = wxPen(color, 1, wxSOLID)
+        self.bgbrush = wx.Brush(color)
+        self.bgpen = wx.Pen(color, 1, wx.SOLID)
     def GetForegroundColour(self):
         return self.fgcolor
     def SetForegroundColour(self, color):
         self.fgcolor = color
     def GetForegroundColour(self):
         return self.fgcolor
     def SetForegroundColour(self, color):
         self.fgcolor = color
-        self.fgbrush = wxBrush(color)
-        self.fgpen = wxPen(color, 1, wxSOLID)
+        self.fgbrush = wx.Brush(color)
+        self.fgpen = wx.Pen(color, 1, wx.SOLID)
     def GetLineColour(self):
         return self.linecolor
     def SetLineColour(self, color):
         self.linecolor = color
     def GetLineColour(self):
         return self.linecolor
     def SetLineColour(self, color):
         self.linecolor = color
-        self.linebrush = wxBrush(color)
-        self.linepen = wxPen( color, 1, wxSOLID)
+        self.linebrush = wx.Brush(color)
+        self.linepen = wx.Pen( color, 1, wx.SOLID)
     def GetForegroundPen(self):
         return self.fgpen
     def GetBackgroundPen(self):
     def GetForegroundPen(self):
         return self.fgpen
     def GetBackgroundPen(self):
@@ -212,7 +243,7 @@ class Painter:
         evt.Skip()
 
 
         evt.Skip()
 
 
-class wxTreeModel:
+class TreeModel:
     """
     Interface for tree models
     """
     """
     Interface for tree models
     """
@@ -281,7 +312,7 @@ class TextConverter:
         raise NotImplementedError
 
 
         raise NotImplementedError
 
 
-class BasicTreeModel(wxTreeModel):
+class BasicTreeModel(TreeModel):
     """
     A very simple treemodel implementation, but flexible enough for many needs.
     """
     """
     A very simple treemodel implementation, but flexible enough for many needs.
     """
@@ -309,21 +340,21 @@ class BasicTreeModel(wxTreeModel):
         if not self.children.has_key(parent):
             self.children[parent]=[]
         self.children[parent].append(child)
         if not self.children.has_key(parent):
             self.children[parent]=[]
         self.children[parent].append(child)
-        wxTreeModel.AddChild(self, parent, child)
+        TreeModel.AddChild(self, parent, child)
         return child
 
     def RemoveNode(self, node):
         parent = self.parents[node]
         del self.parents[node]
         self.children[parent].remove(node)
         return child
 
     def RemoveNode(self, node):
         parent = self.parents[node]
         del self.parents[node]
         self.children[parent].remove(node)
-        wxTreeModel.RemoveNode(self, node)
+        TreeModel.RemoveNode(self, node)
 
     def InsertChild(self, parent, child, index):
         self.parents[child]=parent
         if not self.children.has_key(parent):
             self.children[parent]=[]
         self.children[parent].insert(child, index)
 
     def InsertChild(self, parent, child, index):
         self.parents[child]=parent
         if not self.children.has_key(parent):
             self.children[parent]=[]
         self.children[parent].insert(child, index)
-        wxTreeModel.InsertChild(self, parent, child, index)
+        TreeModel.InsertChild(self, parent, child, index)
         return child
 
     def IsLeaf(self, node):
         return child
 
     def IsLeaf(self, node):
@@ -348,9 +379,9 @@ class FileEditor(Editor):
         self.editcomp.SetSelection(0, len(node.fileName))
         self.editcomp.SetFocus()
         self.treenode = treenode
         self.editcomp.SetSelection(0, len(node.fileName))
         self.editcomp.SetFocus()
         self.treenode = treenode
-#        EVT_KEY_DOWN(self.editcomp, self._key)
-        EVT_KEY_UP(self.editcomp, self._key)
-        EVT_LEFT_DOWN(self.editcomp, self._mdown)
+#        self.editcomp.Bind(wx.EVT_KEY_DOWN, self._key)
+        self.editcomp.Bind(wx.EVT_KEY_UP, self._key)
+        self.editcomp.Bind(wx.EVT_LEFT_DOWN, self._mdown)
         self.editcomp.CaptureMouse()
 
     def CanEdit(self, node):
         self.editcomp.CaptureMouse()
 
     def CanEdit(self, node):
@@ -373,18 +404,18 @@ class FileEditor(Editor):
 
 
     def _key(self, evt):
 
 
     def _key(self, evt):
-        if evt.KeyCode() == WXK_RETURN:
+        if evt.KeyCode() == wx.WXK_RETURN:
             self.EndEdit(True)
             self.EndEdit(True)
-        elif evt.KeyCode() == WXK_ESCAPE:
+        elif evt.KeyCode() == wx.WXK_ESCAPE:
             self.EndEdit(False)
         else:
             evt.Skip()
 
     def _mdown(self, evt):
         if evt.IsButton():
             self.EndEdit(False)
         else:
             evt.Skip()
 
     def _mdown(self, evt):
         if evt.IsButton():
-            pos = evt.GetPosition()
-            edsize = self.editcomp.GetSize()
-            if pos.x < 0 or pos.y < 0 or pos.x > edsize.width or pos.y > edsize.height:
+            x, y = evt.GetPosition()
+            w, h = self.editcomp.GetSize()
+            if x < 0 or y < 0 or x > w or y > h:
                 self.EndEdit(False)
 
 
                 self.EndEdit(False)
 
 
@@ -555,36 +586,36 @@ class TreePainter(Painter):
             for i in range(25):
                 self.charWidths.append(dc.GetTextExtent("D")[0] * i)
             self.charHeight = dc.GetTextExtent("D")[1]
             for i in range(25):
                 self.charWidths.append(dc.GetTextExtent("D")[0] * i)
             self.charHeight = dc.GetTextExtent("D")[1]
-        self.textpen = wxPen(self.GetTextColour(), 1, wxSOLID)
-        self.fgpen = wxPen(self.GetForegroundColour(), 1, wxSOLID)
-        self.bgpen = wxPen(self.GetBackgroundColour(), 1, wxSOLID)
-        self.linepen = wxPen(self.GetLineColour(), 1, wxSOLID)
-        self.dashpen = wxPen(self.GetLineColour(), 1, wxDOT)
-        self.textbrush = wxBrush(self.GetTextColour(), wxSOLID)
-        self.fgbrush = wxBrush(self.GetForegroundColour(), wxSOLID)
-        self.bgbrush = wxBrush(self.GetBackgroundColour(), wxSOLID)
-        self.linebrush = wxPen(self.GetLineColour(), 1, wxSOLID)
+        self.textpen = wx.Pen(self.GetTextColour(), 1, wx.SOLID)
+        self.fgpen = wx.Pen(self.GetForegroundColour(), 1, wx.SOLID)
+        self.bgpen = wx.Pen(self.GetBackgroundColour(), 1, wx.SOLID)
+        self.linepen = wx.Pen(self.GetLineColour(), 1, wx.SOLID)
+        self.dashpen = wx.Pen(self.GetLineColour(), 1, wx.DOT)
+        self.textbrush = wx.Brush(self.GetTextColour(), wx.SOLID)
+        self.fgbrush = wx.Brush(self.GetForegroundColour(), wx.SOLID)
+        self.bgbrush = wx.Brush(self.GetBackgroundColour(), wx.SOLID)
+        self.linebrush = wx.Pen(self.GetLineColour(), 1, wx.SOLID)
         treesize = self.tree.GetSize()
         size = self.tree.transform.GetSize()
         size = (max(treesize.width, size[0]+50), max(treesize.height, size[1]+50))
         dc.BeginDrawing()
         if doubleBuffered:
         treesize = self.tree.GetSize()
         size = self.tree.transform.GetSize()
         size = (max(treesize.width, size[0]+50), max(treesize.height, size[1]+50))
         dc.BeginDrawing()
         if doubleBuffered:
-            mem_dc = wxMemoryDC()
+            mem_dc = wx.MemoryDC()
             if not self.GetBuffer():
                 self.knobs = []
                 self.rectangles = []
             if not self.GetBuffer():
                 self.knobs = []
                 self.rectangles = []
-                self.bmp = wxEmptyBitmap(size[0], size[1])
+                self.bmp = wx.EmptyBitmap(size[0], size[1])
                 mem_dc.SelectObject(self.GetBuffer())
                 mem_dc.SetPen(self.GetBackgroundPen())
                 mem_dc.SetBrush(self.GetBackgroundBrush())
                 mem_dc.SelectObject(self.GetBuffer())
                 mem_dc.SetPen(self.GetBackgroundPen())
                 mem_dc.SetBrush(self.GetBackgroundBrush())
-                mem_dc.DrawRectangle(0, 0, size[0], size[1])
+                mem_dc.DrawRectangle((0, 0), (size[0], size[1]))
                 mem_dc.SetFont(self.tree.GetFont())
                 self.paintWalk(node, mem_dc)
             else:
                 mem_dc.SelectObject(self.GetBuffer())
             xstart, ystart = self.tree.CalcUnscrolledPosition(0,0)
             size = self.tree.GetClientSizeTuple()
                 mem_dc.SetFont(self.tree.GetFont())
                 self.paintWalk(node, mem_dc)
             else:
                 mem_dc.SelectObject(self.GetBuffer())
             xstart, ystart = self.tree.CalcUnscrolledPosition(0,0)
             size = self.tree.GetClientSizeTuple()
-            dc.Blit(xstart, ystart, size[0], size[1], mem_dc, xstart, ystart)
+            dc.Blit((xstart, ystart), (size[0], size[1]), mem_dc, (xstart, ystart))
         else:
             if node == self.tree.currentRoot:
                 self.knobs = []
         else:
             if node == self.tree.currentRoot:
                 self.knobs = []
@@ -593,7 +624,7 @@ class TreePainter(Painter):
             dc.SetBrush(self.GetBackgroundBrush())
             dc.SetFont(self.tree.GetFont())
             if paintBackground:
             dc.SetBrush(self.GetBackgroundBrush())
             dc.SetFont(self.tree.GetFont())
             if paintBackground:
-                dc.DrawRectangle(0, 0, size[0], size[1])
+                dc.DrawRectangle((0, 0), (size[0], size[1]))
             if node:
                 #Call with not paintBackground because if we are told not to paint the
                 #whole background, we have to paint in parts to undo selection coloring.
             if node:
                 #Call with not paintBackground because if we are told not to paint the
                 #whole background, we have to paint in parts to undo selection coloring.
@@ -606,7 +637,7 @@ class TreePainter(Painter):
 
     def SetLinePen(self, pen):
         Painter.SetLinePen(self, pen)
 
     def SetLinePen(self, pen):
         Painter.SetLinePen(self, pen)
-        self.dashpen = wxPen(pen.GetColour(), 1, wxDOT)
+        self.dashpen = wx.Pen(pen.GetColour(), 1, wx.DOT)
 
     def paintWalk(self, node, dc, paintRects=0):
         self.linePainter.Paint(node.parent, node, dc)
 
     def paintWalk(self, node, dc, paintRects=0):
         self.linePainter.Paint(node.parent, node, dc)
@@ -621,23 +652,23 @@ class TreePainter(Painter):
                 if (not self.tree.model.IsLeaf(kid.data)) or ((kid.expanded or self.tree._assumeChildren) and len(kid.kids)):
                     dc.SetPen(self.linepen)
                     dc.SetBrush(self.bgbrush)
                 if (not self.tree.model.IsLeaf(kid.data)) or ((kid.expanded or self.tree._assumeChildren) and len(kid.kids)):
                     dc.SetPen(self.linepen)
                     dc.SetBrush(self.bgbrush)
-                    dc.DrawRectangle(px -4, py-4, 9, 9)
+                    dc.DrawRectangle((px -4, py-4), (9, 9))
                     self.knobs.append( (kid, Rect(px -4, py -4, 9, 9)) )
                     dc.SetPen(self.textpen)
                     if not kid.expanded:
                     self.knobs.append( (kid, Rect(px -4, py -4, 9, 9)) )
                     dc.SetPen(self.textpen)
                     if not kid.expanded:
-                        dc.DrawLine(px, py -2, px, py + 3)
-                    dc.DrawLine(px -2, py, px + 3, py)
+                        dc.DrawLine((px, py -2), (px, py + 3))
+                    dc.DrawLine((px -2, py), (px + 3, py))
         if node == self.tree.currentRoot:
             px = (node.projx - self.tree.layout.NODE_STEP) + 5
             py = node.projy + node.height/2
             dc.SetPen(self.linepen)
             dc.SetBrush(self.bgbrush)
         if node == self.tree.currentRoot:
             px = (node.projx - self.tree.layout.NODE_STEP) + 5
             py = node.projy + node.height/2
             dc.SetPen(self.linepen)
             dc.SetBrush(self.bgbrush)
-            dc.DrawRectangle(px -4, py-4, 9, 9)
+            dc.DrawRectangle((px -4, py-4), (9, 9))
             self.knobs.append( (node, Rect(px -4, py -4, 9, 9)) )
             dc.SetPen(self.textpen)
             if not node.expanded:
             self.knobs.append( (node, Rect(px -4, py -4, 9, 9)) )
             dc.SetPen(self.textpen)
             if not node.expanded:
-                dc.DrawLine(px, py -2, px, py + 3)
-            dc.DrawLine(px -2, py, px + 3, py)
+                dc.DrawLine((px, py -2), (px, py + 3))
+            dc.DrawLine((px -2, py), (px + 3, py))
         return True
 
     def OnMouse(self, evt):
         return True
 
     def OnMouse(self, evt):
@@ -652,15 +683,15 @@ class TreeNodePainter(NodePainter):
         if node.selected:
             dc.SetPen(self.painter.GetLinePen())
             dc.SetBrush(self.painter.GetForegroundBrush())
         if node.selected:
             dc.SetPen(self.painter.GetLinePen())
             dc.SetBrush(self.painter.GetForegroundBrush())
-            dc.SetTextForeground(wxNamedColour("WHITE"))
-            dc.DrawRectangle(node.projx -1, node.projy -1, node.width + 3, node.height + 3)
+            dc.SetTextForeground(wx.NamedColour("WHITE"))
+            dc.DrawRectangle((node.projx -1, node.projy -1), (node.width + 3, node.height + 3))
         else:
             if drawRects:
                 dc.SetBrush(self.painter.GetBackgroundBrush())
                 dc.SetPen(self.painter.GetBackgroundPen())
         else:
             if drawRects:
                 dc.SetBrush(self.painter.GetBackgroundBrush())
                 dc.SetPen(self.painter.GetBackgroundPen())
-                dc.DrawRectangle(node.projx -1, node.projy -1, node.width + 3, node.height + 3)
+                dc.DrawRectangle((node.projx -1, node.projy -1), (node.width + 3, node.height + 3))
             dc.SetTextForeground(self.painter.GetTextColour())
             dc.SetTextForeground(self.painter.GetTextColour())
-        dc.DrawText(text, node.projx, node.projy)
+        dc.DrawText(text, (node.projx, node.projy))
         self.painter.rectangles.append((node, Rect(node.projx, node.projy, node.width, node.height)))
 
 class TreeLinePainter(LinePainter):
         self.painter.rectangles.append((node, Rect(node.projx, node.projy, node.width, node.height)))
 
 class TreeLinePainter(LinePainter):
@@ -672,59 +703,41 @@ class TreeLinePainter(LinePainter):
             py = child.projy + self.painter.tree.layout.NODE_HEIGHT/2 -2
             cx = child.projx
             cy = py
             py = child.projy + self.painter.tree.layout.NODE_HEIGHT/2 -2
             cx = child.projx
             cy = py
-            dc.DrawLine(px, py, cx, cy)
+            dc.DrawLine((px, py), (cx, cy))
         else:
             px = parent.projx + 5
             py = parent.projy + parent.height
             cx = child.projx -5
             cy = child.projy + self.painter.tree.layout.NODE_HEIGHT/2 -3
         else:
             px = parent.projx + 5
             py = parent.projy + parent.height
             cx = child.projx -5
             cy = child.projy + self.painter.tree.layout.NODE_HEIGHT/2 -3
-            dc.DrawLine(px, py, px, cy)
-            dc.DrawLine(px, cy, cx, cy)
-
-
-wxEVT_MVCTREE_BEGIN_EDIT = 20204 #Start editing. Vetoable.
-wxEVT_MVCTREE_END_EDIT = 20205 #Stop editing. Vetoable.
-wxEVT_MVCTREE_DELETE_ITEM = 20206 #Item removed from model.
-wxEVT_MVCTREE_ITEM_EXPANDED = 20209
-wxEVT_MVCTREE_ITEM_EXPANDING = 20210
-wxEVT_MVCTREE_ITEM_COLLAPSED = 20211
-wxEVT_MVCTREE_ITEM_COLLAPSING = 20212
-wxEVT_MVCTREE_SEL_CHANGED = 20213
-wxEVT_MVCTREE_SEL_CHANGING = 20214 #Vetoable.
-wxEVT_MVCTREE_KEY_DOWN = 20215
-wxEVT_MVCTREE_ADD_ITEM = 20216 #Item added to model.
-
-def EVT_MVCTREE_SEL_CHANGED(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_SEL_CHANGED, func)
-
-def EVT_MVCTREE_SEL_CHANGING(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_SEL_CHANGING, func)
-
-def EVT_MVCTREE_ITEM_EXPANDED(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_ITEM_EXPANDED, func)
-
-def EVT_MVCTREE_ITEM_EXPANDING(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_ITEM_EXPANDING, func)
-
-def EVT_MVCTREE_ITEM_COLLAPSED(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_ITEM_COLLAPSED, func)
-
-def EVT_MVCTREE_ITEM_COLLAPSING(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_ITEM_COLLAPSING, func)
-
-def EVT_MVCTREE_ADD_ITEM(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_ADD_ITEM, func)
-
-def EVT_MVCTREE_DELETE_ITEM(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_DELETE_ITEM, func)
-
-def EVT_MVCTREE_KEY_DOWN(win, id, func):
-    win.Connect(id, -1, wxEVT_MVCTREE_KEY_DOWN, func)
-
-
-class wxMVCTreeEvent(wxPyCommandEvent):
+            dc.DrawLine((px, py), (px, cy))
+            dc.DrawLine((px, cy), (cx, cy))
+
+#>> Event defs
+wxEVT_MVCTREE_BEGIN_EDIT = wx.NewEventType() #Start editing. Vetoable.
+wxEVT_MVCTREE_END_EDIT = wx.NewEventType() #Stop editing. Vetoable.
+wxEVT_MVCTREE_DELETE_ITEM = wx.NewEventType() #Item removed from model.
+wxEVT_MVCTREE_ITEM_EXPANDED = wx.NewEventType()
+wxEVT_MVCTREE_ITEM_EXPANDING = wx.NewEventType()
+wxEVT_MVCTREE_ITEM_COLLAPSED = wx.NewEventType()
+wxEVT_MVCTREE_ITEM_COLLAPSING = wx.NewEventType()
+wxEVT_MVCTREE_SEL_CHANGED = wx.NewEventType()
+wxEVT_MVCTREE_SEL_CHANGING = wx.NewEventType() #Vetoable.
+wxEVT_MVCTREE_KEY_DOWN = wx.NewEventType()
+wxEVT_MVCTREE_ADD_ITEM = wx.NewEventType() #Item added to model.
+
+EVT_MVCTREE_SEL_CHANGED = wx.PyEventBinder(wxEVT_MVCTREE_SEL_CHANGED, 1)
+EVT_MVCTREE_SEL_CHANGING = wx.PyEventBinder(wxEVT_MVCTREE_SEL_CHANGING, 1)
+EVT_MVCTREE_ITEM_EXPANDED = wx.PyEventBinder(wxEVT_MVCTREE_ITEM_EXPANDED, 1)
+EVT_MVCTREE_ITEM_EXPANDING = wx.PyEventBinder(wxEVT_MVCTREE_ITEM_EXPANDING, 1)
+EVT_MVCTREE_ITEM_COLLAPSED = wx.PyEventBinder(wxEVT_MVCTREE_ITEM_COLLAPSED, 1)
+EVT_MVCTREE_ITEM_COLLAPSING = wx.PyEventBinder(wxEVT_MVCTREE_ITEM_COLLAPSING, 1)
+EVT_MVCTREE_ADD_ITEM = wx.PyEventBinder(wxEVT_MVCTREE_ADD_ITEM, 1)
+EVT_MVCTREE_DELETE_ITEM = wx.PyEventBinder(wxEVT_MVCTREE_DELETE_ITEM, 1)
+EVT_MVCTREE_KEY_DOWN = wx.PyEventBinder(wxEVT_MVCTREE_KEY_DOWN, 1)
+
+class MVCTreeEvent(wx.PyCommandEvent):
     def __init__(self, type, id, node = None, nodes = None, keyEvent = None, **kwargs):
     def __init__(self, type, id, node = None, nodes = None, keyEvent = None, **kwargs):
-        apply(wxPyCommandEvent.__init__, (self, type, id), kwargs)
+        apply(wx.PyCommandEvent.__init__, (self, type, id), kwargs)
         self.node = node
         self.nodes = nodes
         self.keyEvent = keyEvent
         self.node = node
         self.nodes = nodes
         self.keyEvent = keyEvent
@@ -735,20 +748,20 @@ class wxMVCTreeEvent(wxPyCommandEvent):
     def getKeyEvent(self):
         return self.keyEvent
 
     def getKeyEvent(self):
         return self.keyEvent
 
-class wxMVCTreeNotifyEvent(wxMVCTreeEvent):
+class MVCTreeNotifyEvent(MVCTreeEvent):
     def __init__(self, type, id, node = None, nodes = None, **kwargs):
     def __init__(self, type, id, node = None, nodes = None, **kwargs):
-        apply(wxMVCTreeEvent.__init__, (self, type, id, node, nodes), kwargs)
-        self.notify = wxNotifyEvent(type, id)
+        apply(MVCTreeEvent.__init__, (self, type, id, node, nodes), kwargs)
+        self.notify = wx.NotifyEvent(type, id)
     def getNotifyEvent(self):
         return self.notify
 
     def getNotifyEvent(self):
         return self.notify
 
-class wxMVCTree(wxScrolledWindow):
+class MVCTree(wx.ScrolledWindow):
     """
     The main mvc tree class.
     """
     def __init__(self, parent, id, model = None, layout = None, transform = None,
                  painter = None, *args, **kwargs):
     """
     The main mvc tree class.
     """
     def __init__(self, parent, id, model = None, layout = None, transform = None,
                  painter = None, *args, **kwargs):
-        apply(wxScrolledWindow.__init__, (self, parent, id), kwargs)
+        apply(wx.ScrolledWindow.__init__, (self, parent, id), kwargs)
         self.nodemap = {}
         self._multiselect = False
         self._selections = []
         self.nodemap = {}
         self._multiselect = False
         self._selections = []
@@ -771,19 +784,19 @@ class wxMVCTree(wxScrolledWindow):
         if not painter:
             painter = TreePainter(self)
         self.painter = painter
         if not painter:
             painter = TreePainter(self)
         self.painter = painter
-        self.SetFont(wxFont(9, wxDEFAULT, wxNORMAL, wxNORMAL, False))
-        EVT_MOUSE_EVENTS(self, self.OnMouse)
-        EVT_KEY_DOWN(self, self.OnKeyDown)
+        self.SetFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False))
+        self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse)
+        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
         self.doubleBuffered = True
         self.doubleBuffered = True
-        EVT_SIZE(self, self.OnSize)
-        EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
-        EVT_PAINT(self, self.OnPaint)
+        self.Bind(wx.EVT_SIZE, self.OnSize)
+        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
+        self.Bind(wx.EVT_PAINT, self.OnPaint)
 
 
     def Refresh(self):
         if self.doubleBuffered:
             self.painter.ClearBuffer()
 
 
     def Refresh(self):
         if self.doubleBuffered:
             self.painter.ClearBuffer()
-        wxScrolledWindow.Refresh(self, False)
+        wx.ScrolledWindow.Refresh(self, False)
 
     def GetPainter(self):
         return self.painter
 
     def GetPainter(self):
         return self.painter
@@ -795,33 +808,33 @@ class wxMVCTree(wxScrolledWindow):
         return self.transform
 
     def __repr__(self):
         return self.transform
 
     def __repr__(self):
-        return "<wxMVCTree instance at %s>" % str(hex(id(self)))
+        return "<MVCTree instance at %s>" % str(hex(id(self)))
 
     def __str__(self):
         return self.__repr__()
 
     def NodeAdded(self, parent, child):
 
     def __str__(self):
         return self.__repr__()
 
     def NodeAdded(self, parent, child):
-        e = wxMVCTreeEvent(wxEVT_MVCTREE_ADD_ITEM, self.GetId(), node = child, nodes = [parent, child])
+        e = MVCTreeEvent(wxEVT_MVCTREE_ADD_ITEM, self.GetId(), node = child, nodes = [parent, child])
         self.GetEventHandler().ProcessEvent(e)
         self.painter.ClearBuffer()
 
     def NodeInserted(self, parent, child, index):
         self.GetEventHandler().ProcessEvent(e)
         self.painter.ClearBuffer()
 
     def NodeInserted(self, parent, child, index):
-        e = wxMVCTreeEvent(wxEVT_MVCTREE_ADD_ITEM, self.GetId(), node = child, nodes = [parent, child])
+        e = MVCTreeEvent(wxEVT_MVCTREE_ADD_ITEM, self.GetId(), node = child, nodes = [parent, child])
         self.GetEventHandler().ProcessEvent(e)
         self.painter.ClearBuffer()
 
     def NodeRemoved(self, node):
         self.GetEventHandler().ProcessEvent(e)
         self.painter.ClearBuffer()
 
     def NodeRemoved(self, node):
-        e = wxMVCTreeEvent(wxEVT_MVCTREE_DELETE_ITEM, self.GetId(), node = child, nodes = [parent, child])
+        e = MVCTreeEvent(wxEVT_MVCTREE_DELETE_ITEM, self.GetId(), node = child, nodes = [parent, child])
         self.GetEventHandler().ProcessEvent(e)
         self.painter.ClearBuffer()
 
     def OnKeyDown(self, evt):
         self.GetEventHandler().ProcessEvent(e)
         self.painter.ClearBuffer()
 
     def OnKeyDown(self, evt):
-        e = wxMVCTreeEvent(wxEVT_MVCTREE_KEY_DOWN, self.GetId(), keyEvent = evt)
+        e = MVCTreeEvent(wxEVT_MVCTREE_KEY_DOWN, self.GetId(), keyEvent = evt)
         self.GetEventHandler().ProcessEvent(e)
 
     def SetFont(self, font):
         self.painter.SetFont(font)
         self.GetEventHandler().ProcessEvent(e)
 
     def SetFont(self, font):
         self.painter.SetFont(font)
-        dc = wxClientDC(self)
+        dc = wx.ClientDC(self)
         dc.SetFont(font)
         self.layout.SetHeight(dc.GetTextExtent("")[1] + 18)
         self.painter.ClearBuffer()
         dc.SetFont(font)
         self.layout.SetHeight(dc.GetTextExtent("")[1] + 18)
         self.painter.ClearBuffer()
@@ -856,7 +869,7 @@ class wxMVCTree(wxScrolledWindow):
 
     def SetDoubleBuffered(self, bool):
         """
 
     def SetDoubleBuffered(self, bool):
         """
-        By default wxMVCTree is double-buffered.
+        By default MVCTree is double-buffered.
         """
         self.doubleBuffered = bool
 
         """
         self.doubleBuffered = bool
 
@@ -917,7 +930,7 @@ class wxMVCTree(wxScrolledWindow):
     def SetSelection(self, nodeTuple):
         if type(nodeTuple) != type(()):
             nodeTuple = (nodeTuple,)
     def SetSelection(self, nodeTuple):
         if type(nodeTuple) != type(()):
             nodeTuple = (nodeTuple,)
-        e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_SEL_CHANGING, self.GetId(), nodeTuple[0], nodes = nodeTuple)
+        e = MVCTreeNotifyEvent(wxEVT_MVCTREE_SEL_CHANGING, self.GetId(), nodeTuple[0], nodes = nodeTuple)
         self.GetEventHandler().ProcessEvent(e)
         if not e.notify.IsAllowed():
             return
         self.GetEventHandler().ProcessEvent(e)
         if not e.notify.IsAllowed():
             return
@@ -928,7 +941,7 @@ class wxMVCTree(wxScrolledWindow):
             treenode = self.nodemap[node]
             node.selected = False
         self._selections = list(nodeTuple)
             treenode = self.nodemap[node]
             node.selected = False
         self._selections = list(nodeTuple)
-        e = wxMVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), nodeTuple[0], nodes = nodeTuple)
+        e = MVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), nodeTuple[0], nodes = nodeTuple)
         self.GetEventHandler().ProcessEvent(e)
 
     def IsMultiSelect(self):
         self.GetEventHandler().ProcessEvent(e)
 
     def IsMultiSelect(self):
@@ -945,7 +958,7 @@ class wxMVCTree(wxScrolledWindow):
             return
         for ed in self._editors:
             if ed.CanEdit(node):
             return
         for ed in self._editors:
             if ed.CanEdit(node):
-                e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_BEGIN_EDIT, self.GetId(), node)
+                e = MVCTreeNotifyEvent(wxEVT_MVCTREE_BEGIN_EDIT, self.GetId(), node)
                 self.GetEventHandler().ProcessEvent(e)
                 if not e.notify.IsAllowed():
                     return
                 self.GetEventHandler().ProcessEvent(e)
                 if not e.notify.IsAllowed():
                     return
@@ -959,7 +972,7 @@ class wxMVCTree(wxScrolledWindow):
             self._currentEditor = None
 
     def _EditEnding(self, node):
             self._currentEditor = None
 
     def _EditEnding(self, node):
-        e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_END_EDIT, self.GetId(), node)
+        e = MVCTreeNotifyEvent(wxEVT_MVCTREE_END_EDIT, self.GetId(), node)
         self.GetEventHandler().ProcessEvent(e)
         if not e.notify.IsAllowed():
             return False
         self.GetEventHandler().ProcessEvent(e)
         if not e.notify.IsAllowed():
             return False
@@ -970,23 +983,23 @@ class wxMVCTree(wxScrolledWindow):
     def SetExpanded(self, node, bool):
         treenode = self.nodemap[node]
         if bool:
     def SetExpanded(self, node, bool):
         treenode = self.nodemap[node]
         if bool:
-            e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_ITEM_EXPANDING, self.GetId(), node)
+            e = MVCTreeNotifyEvent(wxEVT_MVCTREE_ITEM_EXPANDING, self.GetId(), node)
             self.GetEventHandler().ProcessEvent(e)
             if not e.notify.IsAllowed():
                 return
             if not treenode.built:
                 self.LoadChildren(treenode)
         else:
             self.GetEventHandler().ProcessEvent(e)
             if not e.notify.IsAllowed():
                 return
             if not treenode.built:
                 self.LoadChildren(treenode)
         else:
-            e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_ITEM_COLLAPSING, self.GetId(), node)
+            e = MVCTreeNotifyEvent(wxEVT_MVCTREE_ITEM_COLLAPSING, self.GetId(), node)
             self.GetEventHandler().ProcessEvent(e)
             if not e.notify.IsAllowed():
                 return
         treenode.expanded = bool
         e = None
         if treenode.expanded:
             self.GetEventHandler().ProcessEvent(e)
             if not e.notify.IsAllowed():
                 return
         treenode.expanded = bool
         e = None
         if treenode.expanded:
-            e = wxMVCTreeEvent(wxEVT_MVCTREE_ITEM_EXPANDED, self.GetId(), node)
+            e = MVCTreeEvent(wxEVT_MVCTREE_ITEM_EXPANDED, self.GetId(), node)
         else:
         else:
-            e = wxMVCTreeEvent(wxEVT_MVCTREE_ITEM_COLLAPSED, self.GetId(), node)
+            e = MVCTreeEvent(wxEVT_MVCTREE_ITEM_COLLAPSED, self.GetId(), node)
         self.GetEventHandler().ProcessEvent(e)
         self.layout.Layout(self.currentRoot)
         self.transform.Transform(self.currentRoot, self.offset, self.rotation)
         self.GetEventHandler().ProcessEvent(e)
         self.layout.Layout(self.currentRoot)
         self.transform.Transform(self.currentRoot, self.offset, self.rotation)
@@ -999,7 +1012,7 @@ class wxMVCTree(wxScrolledWindow):
         nodeTuple = nodeOrTuple
         if type(nodeOrTuple)!= type(()):
             nodeTuple = (nodeOrTuple,)
         nodeTuple = nodeOrTuple
         if type(nodeOrTuple)!= type(()):
             nodeTuple = (nodeOrTuple,)
-        e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_SEL_CHANGING, self.GetId(), nodeTuple[0], nodes = nodeTuple)
+        e = MVCTreeNotifyEvent(wxEVT_MVCTREE_SEL_CHANGING, self.GetId(), nodeTuple[0], nodes = nodeTuple)
         self.GetEventHandler().ProcessEvent(e)
         if not e.notify.IsAllowed():
             return
         self.GetEventHandler().ProcessEvent(e)
         if not e.notify.IsAllowed():
             return
@@ -1040,9 +1053,9 @@ class wxMVCTree(wxScrolledWindow):
                         treenode = self.nodemap[node]
                         treenode.selected = True
                         changeparents.append(treenode)
                         treenode = self.nodemap[node]
                         treenode.selected = True
                         changeparents.append(treenode)
-        e = wxMVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), nodeTuple[0], nodes = nodeTuple)
+        e = MVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), nodeTuple[0], nodes = nodeTuple)
         self.GetEventHandler().ProcessEvent(e)
         self.GetEventHandler().ProcessEvent(e)
-        dc = wxClientDC(self)
+        dc = wx.ClientDC(self)
         self.PrepareDC(dc)
         for node in changeparents:
             if node:
         self.PrepareDC(dc)
         for node in changeparents:
             if node:
@@ -1058,9 +1071,9 @@ class wxMVCTree(wxScrolledWindow):
             treenode = self.nodemap[node]
             changeparents.append(treenode)
             treenode.selected = False
             treenode = self.nodemap[node]
             changeparents.append(treenode)
             treenode.selected = False
-        e = wxMVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), node, nodes = nodeTuple)
+        e = MVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), node, nodes = nodeTuple)
         self.GetEventHandler().ProcessEvent(e)
         self.GetEventHandler().ProcessEvent(e)
-        dc = wxClientDC(self)
+        dc = wx.ClientDC(self)
         self.PrepareDC(dc)
         for node in changeparents:
             if node:
         self.PrepareDC(dc)
         for node in changeparents:
             if node:
@@ -1072,22 +1085,22 @@ class wxMVCTree(wxScrolledWindow):
         if hasattr(self, 'painter') and self.painter:
             return self.painter.GetBackgroundColour()
         else:
         if hasattr(self, 'painter') and self.painter:
             return self.painter.GetBackgroundColour()
         else:
-            return wxWindow.GetBackgroundColour(self)
+            return wx.Window.GetBackgroundColour(self)
     def SetBackgroundColour(self, color):
         if hasattr(self, 'painter') and self.painter:
             self.painter.SetBackgroundColour(color)
         else:
     def SetBackgroundColour(self, color):
         if hasattr(self, 'painter') and self.painter:
             self.painter.SetBackgroundColour(color)
         else:
-            wxWindow.SetBackgroundColour(self, color)
+            wx.Window.SetBackgroundColour(self, color)
     def GetForegroundColour(self):
         if hasattr(self, 'painter') and self.painter:
             return self.painter.GetForegroundColour()
         else:
     def GetForegroundColour(self):
         if hasattr(self, 'painter') and self.painter:
             return self.painter.GetForegroundColour()
         else:
-            return wxWindow.GetBackgroundColour(self)
+            return wx.Window.GetBackgroundColour(self)
     def SetForegroundColour(self, color):
         if hasattr(self, 'painter') and self.painter:
             self.painter.SetForegroundColour(color)
         else:
     def SetForegroundColour(self, color):
         if hasattr(self, 'painter') and self.painter:
             self.painter.SetForegroundColour(color)
         else:
-            wxWindow.SetBackgroundColour(self, color)
+            wx.Window.SetBackgroundColour(self, color)
 
     def SetAssumeChildren(self, bool):
         self._assumeChildren = bool
 
     def SetAssumeChildren(self, bool):
         self._assumeChildren = bool
@@ -1113,15 +1126,15 @@ class wxMVCTree(wxScrolledWindow):
             tsize = list(self.transform.GetSize())
             tsize[0] = tsize[0] + 50
             tsize[1] = tsize[1] + 50
             tsize = list(self.transform.GetSize())
             tsize[0] = tsize[0] + 50
             tsize[1] = tsize[1] + 50
-            size = self.GetSizeTuple()
-            if tsize[0] > size[0] or tsize[1] > size[1]:
+            w, h = self.GetSize()
+            if tsize[0] > w or tsize[1] > h:
                 if not hasattr(self, '_oldsize') or (tsize[0] > self._oldsize[0] or tsize[1] > self._oldsize[1]):
                     self._oldsize = tsize
                 if not hasattr(self, '_oldsize') or (tsize[0] > self._oldsize[0] or tsize[1] > self._oldsize[1]):
                     self._oldsize = tsize
-                    oldstart = self.ViewStart()
+                    oldstart = self.GetViewStart()
                     self._lastPhysicalSize = self.GetSize()
                     self.SetScrollbars(10, 10, tsize[0]/10, tsize[1]/10)
                     self.Scroll(oldstart[0], oldstart[1])
                     self._lastPhysicalSize = self.GetSize()
                     self.SetScrollbars(10, 10, tsize[0]/10, tsize[1]/10)
                     self.Scroll(oldstart[0], oldstart[1])
-            dc = wxPaintDC(self)
+            dc = wx.PaintDC(self)
             self.PrepareDC(dc)
             dc.SetFont(self.GetFont())
             self.painter.Paint(dc, self.currentRoot, self.doubleBuffered)
             self.PrepareDC(dc)
             dc.SetFont(self.GetFont())
             self.painter.Paint(dc, self.currentRoot, self.doubleBuffered)
@@ -1130,12 +1143,3 @@ class wxMVCTree(wxScrolledWindow):
 
 
 
 
 
 
-
-
-
-
-
-
-
-
-