2003-07-02 23:13:10 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import wx
|
|
|
|
import wx.gizmos as gizmos
|
2003-07-02 23:13:10 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import images
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestPanel(wx.Panel):
|
2003-07-02 23:13:10 +00:00
|
|
|
def __init__(self, parent, log):
|
|
|
|
self.log = log
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
|
|
|
self.Bind(wx.EVT_SIZE, self.OnSize)
|
2003-07-02 23:13:10 +00:00
|
|
|
|
2004-06-29 02:06:16 +00:00
|
|
|
self.tree = gizmos.TreeListCtrl(self, -1, style =
|
|
|
|
wx.TR_DEFAULT_STYLE
|
|
|
|
#wx.TR_TWIST_BUTTONS
|
|
|
|
#| wx.TR_ROW_LINES
|
|
|
|
#| wx.TR_NO_LINES
|
2004-06-29 02:58:19 +00:00
|
|
|
| wx.TR_FULL_ROW_HIGHLIGHT
|
|
|
|
|
|
|
|
# By default the style will be adjusted on
|
|
|
|
# Mac to use twisty buttons and no lines. If
|
|
|
|
# you would rather control this yourself then
|
|
|
|
# add this style.
|
|
|
|
#| wx.TR_DONT_ADJUST_MAC
|
2003-07-02 23:13:10 +00:00
|
|
|
)
|
2004-06-29 02:58:19 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
isz = (16,16)
|
2003-12-09 01:23:28 +00:00
|
|
|
il = wx.ImageList(isz[0], isz[1])
|
|
|
|
fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz))
|
|
|
|
fldropenidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz))
|
|
|
|
fileidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, isz))
|
2003-07-02 23:13:10 +00:00
|
|
|
smileidx = il.Add(images.getSmilesBitmap())
|
|
|
|
|
|
|
|
self.tree.SetImageList(il)
|
|
|
|
self.il = il
|
|
|
|
|
|
|
|
# create some columns
|
|
|
|
self.tree.AddColumn("Main column")
|
|
|
|
self.tree.AddColumn("Column 1")
|
|
|
|
self.tree.AddColumn("Column 2")
|
|
|
|
self.tree.SetMainColumn(0) # the one with the tree in it...
|
|
|
|
self.tree.SetColumnWidth(0, 175)
|
|
|
|
|
|
|
|
|
|
|
|
self.root = self.tree.AddRoot("The Root Item")
|
|
|
|
self.tree.SetItemText(self.root, "col 1 root", 1)
|
|
|
|
self.tree.SetItemText(self.root, "col 2 root", 2)
|
2003-12-09 01:23:28 +00:00
|
|
|
self.tree.SetItemImage(self.root, fldridx, which = wx.TreeItemIcon_Normal)
|
|
|
|
self.tree.SetItemImage(self.root, fldropenidx, which = wx.TreeItemIcon_Expanded)
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
for x in range(15):
|
|
|
|
txt = "Item %d" % x
|
|
|
|
child = self.tree.AppendItem(self.root, txt)
|
|
|
|
self.tree.SetItemText(child, txt + "(c1)", 1)
|
|
|
|
self.tree.SetItemText(child, txt + "(c2)", 2)
|
2003-12-09 01:23:28 +00:00
|
|
|
self.tree.SetItemImage(child, fldridx, which = wx.TreeItemIcon_Normal)
|
|
|
|
self.tree.SetItemImage(child, fldropenidx, which = wx.TreeItemIcon_Expanded)
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
for y in range(5):
|
|
|
|
txt = "item %d-%s" % (x, chr(ord("a")+y))
|
|
|
|
last = self.tree.AppendItem(child, txt)
|
|
|
|
self.tree.SetItemText(last, txt + "(c1)", 1)
|
|
|
|
self.tree.SetItemText(last, txt + "(c2)", 2)
|
2003-12-09 01:23:28 +00:00
|
|
|
self.tree.SetItemImage(last, fldridx, which = wx.TreeItemIcon_Normal)
|
|
|
|
self.tree.SetItemImage(last, fldropenidx, which = wx.TreeItemIcon_Expanded)
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
for z in range(5):
|
|
|
|
txt = "item %d-%s-%d" % (x, chr(ord("a")+y), z)
|
|
|
|
item = self.tree.AppendItem(last, txt)
|
|
|
|
self.tree.SetItemText(item, txt + "(c1)", 1)
|
|
|
|
self.tree.SetItemText(item, txt + "(c2)", 2)
|
2003-12-09 01:23:28 +00:00
|
|
|
self.tree.SetItemImage(item, fileidx, which = wx.TreeItemIcon_Normal)
|
|
|
|
self.tree.SetItemImage(item, smileidx, which = wx.TreeItemIcon_Selected)
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
self.tree.Expand(self.root)
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
|
2003-10-06 16:53:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
def OnRightUp(self, evt):
|
|
|
|
pos = evt.GetPosition()
|
|
|
|
item, flags, col = self.tree.HitTest(pos)
|
|
|
|
if item:
|
2004-08-11 22:24:47 +00:00
|
|
|
self.log.write('Flags: %s, Col:%s, Text: %s' %
|
|
|
|
(flags, col, self.tree.GetItemText(item, col)))
|
2003-10-06 16:53:31 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
def OnSize(self, evt):
|
|
|
|
self.tree.SetSize(self.GetSize())
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
overview = """<html><body>
|
2004-01-13 03:17:17 +00:00
|
|
|
<h2><center>TreeListCtrl</center></h2>
|
2003-07-02 23:13:10 +00:00
|
|
|
|
2004-01-13 03:17:17 +00:00
|
|
|
The TreeListCtrl is essentially a wx.TreeCtrl with extra columns,
|
2003-12-09 01:23:28 +00:00
|
|
|
such that the look is similar to a wx.ListCtrl.
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
</body></html>
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
#raw_input("Press enter...")
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
2003-07-02 23:13:10 +00:00
|
|
|
|