def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "CustomTreeCtrl Demo")
# Create a CustomTreeCtrl instance
custom_tree = CT.CustomTreeCtrl(self, agwStyle=wx.TR_DEFAULT_STYLE)
# Add a root node to it
root = custom_tree.AddRoot("The Root Item")
# Create an image list to add icons next to an item
il = wx.ImageList(16, 16)
fldridx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, (16, 16)))
fldropenidx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, (16, 16)))
fileidx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, (16, 16)))
custom_tree.SetImageList(il)
custom_tree.SetItemImage(root, fldridx, wx.TreeItemIcon_Normal)
custom_tree.SetItemImage(root, fldropenidx, wx.TreeItemIcon_Expanded)
list = [ 'http://app.finance.china.com.cn/forex',
'http://app.finance.china.com.cn/report/list.php',
'http://app.finance.china.com.cn/stock/bill']
for x in list:
child = custom_tree.AppendItem(root, "Item %s" % x)
custom_tree.SetItemImage(child, fldridx, wx.TreeItemIcon_Normal)
custom_tree.SetItemImage(child, fldropenidx, wx.TreeItemIcon_Expanded)
for y in list:
last = custom_tree.AppendItem(child, "item-%s-%s" % (x,y))
custom_tree.SetItemImage(last, fldridx, wx.TreeItemIcon_Normal)
custom_tree.SetItemImage(last, fldropenidx, wx.TreeItemIcon_Expanded)
for z in list:
item = custom_tree.AppendItem(last, "item %s-%s-%s" % (x,y,z))
custom_tree.SetItemImage(item, fileidx, wx.TreeItemIcon_Normal)
custom_tree.Expand(root)
# our normal wxApp-derived class, as usual
评论列表
文章目录