Use native wx.TreeCtrl by default, but make it easy to switch back to
CustomTreeCtrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45904 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,11 +34,11 @@ import sys, os, time, traceback, types
|
|||||||
import wx # This module uses the new wx namespace
|
import wx # This module uses the new wx namespace
|
||||||
import wx.aui
|
import wx.aui
|
||||||
import wx.html
|
import wx.html
|
||||||
import wx.lib.customtreectrl as CT
|
|
||||||
from wx.lib.mixins.treemixin import ExpansionState
|
|
||||||
|
|
||||||
import images
|
import images
|
||||||
|
|
||||||
|
USE_CUSTOMTREECTRL = False
|
||||||
|
|
||||||
# For debugging
|
# For debugging
|
||||||
##wx.Trap();
|
##wx.Trap();
|
||||||
##print "wx.VERSION_STRING = %s (%s)" % (wx.VERSION_STRING, wx.USE_UNICODE and 'unicode' or 'ansi')
|
##print "wx.VERSION_STRING = %s (%s)" % (wx.VERSION_STRING, wx.USE_UNICODE and 'unicode' or 'ansi')
|
||||||
@@ -1505,6 +1505,7 @@ class wxPythonDemo(wx.Frame):
|
|||||||
firstChild = None
|
firstChild = None
|
||||||
filter = self.filter.GetValue()
|
filter = self.filter.GetValue()
|
||||||
count = 0
|
count = 0
|
||||||
|
if USE_CUSTOMTREECTRL:
|
||||||
bmp = images.catalog['modifiedexists'].getBitmap()
|
bmp = images.catalog['modifiedexists'].getBitmap()
|
||||||
for category, items in _treeList:
|
for category, items in _treeList:
|
||||||
count += 1
|
count += 1
|
||||||
@@ -1519,10 +1520,9 @@ class wxPythonDemo(wx.Frame):
|
|||||||
self.tree.SetPyData(child, count)
|
self.tree.SetPyData(child, count)
|
||||||
if not firstChild: firstChild = child
|
if not firstChild: firstChild = child
|
||||||
for childItem in items:
|
for childItem in items:
|
||||||
if DoesModifiedExist(childItem):
|
|
||||||
wnd = wx.StaticBitmap(self.tree, -1, bmp)
|
|
||||||
else:
|
|
||||||
wnd = None
|
wnd = None
|
||||||
|
if USE_CUSTOMTREECTRL and DoesModifiedExist(childItem):
|
||||||
|
wnd = wx.StaticBitmap(self.tree, -1, bmp)
|
||||||
theDemo = self.tree.AppendItem(child, childItem, image=count, wnd=wnd)
|
theDemo = self.tree.AppendItem(child, childItem, image=count, wnd=wnd)
|
||||||
self.tree.SetPyData(theDemo, count)
|
self.tree.SetPyData(theDemo, count)
|
||||||
self.treeMap[childItem] = theDemo
|
self.treeMap[childItem] = theDemo
|
||||||
@@ -2074,28 +2074,46 @@ class MySplashScreen(wx.SplashScreen):
|
|||||||
self.Raise()
|
self.Raise()
|
||||||
|
|
||||||
|
|
||||||
class wxPythonTreeCtrl(ExpansionState, CT.CustomTreeCtrl):
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
from wx.lib.mixins.treemixin import ExpansionState
|
||||||
|
if USE_CUSTOMTREECTRL:
|
||||||
|
import wx.lib.customtreectrl as CT
|
||||||
|
TreeBaseClass = CT.CustomTreeCtrl
|
||||||
|
else:
|
||||||
|
TreeBaseClass = wx.TreeCtrl
|
||||||
|
|
||||||
|
|
||||||
|
class wxPythonTreeCtrl(ExpansionState, TreeBaseClass):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
CT.CustomTreeCtrl.__init__(self, parent, style=wx.TR_DEFAULT_STYLE|
|
TreeBaseClass.__init__(self, parent, style=wx.TR_DEFAULT_STYLE|
|
||||||
wx.TR_HAS_VARIABLE_ROW_HEIGHT)
|
wx.TR_HAS_VARIABLE_ROW_HEIGHT)
|
||||||
|
self.BuildTreeImageList()
|
||||||
|
if USE_CUSTOMTREECTRL:
|
||||||
self.SetSpacing(10)
|
self.SetSpacing(10)
|
||||||
self.SetWindowStyle(self.GetWindowStyle() & ~wx.TR_LINES_AT_ROOT)
|
self.SetWindowStyle(self.GetWindowStyle() & ~wx.TR_LINES_AT_ROOT)
|
||||||
|
|
||||||
self.BuildTreeImageList()
|
def AppendItem(self, parent, text, image=-1, wnd=None):
|
||||||
|
if USE_CUSTOMTREECTRL:
|
||||||
|
item = TreeBaseClass.AppendItem(self, parent, text, image=image, wnd=wnd)
|
||||||
|
else:
|
||||||
|
item = TreeBaseClass.AppendItem(self, parent, text, image=image)
|
||||||
|
return item
|
||||||
|
|
||||||
def BuildTreeImageList(self):
|
def BuildTreeImageList(self):
|
||||||
imgList = wx.ImageList(16, 16)
|
imgList = wx.ImageList(16, 16)
|
||||||
for png in _demoPngs:
|
for png in _demoPngs:
|
||||||
imgList.Add(images.catalog[png].getBitmap())
|
imgList.Add(images.catalog[png].getBitmap())
|
||||||
|
|
||||||
self.SetImageList(imgList)
|
self.AssignImageList(imgList)
|
||||||
|
|
||||||
|
|
||||||
def GetItemIdentity(self, item):
|
def GetItemIdentity(self, item):
|
||||||
return self.GetPyData(item)
|
return self.GetPyData(item)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class MyApp(wx.App):
|
class MyApp(wx.App):
|
||||||
def OnInit(self):
|
def OnInit(self):
|
||||||
|
Reference in New Issue
Block a user