X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1fded56b375bf7a4687af1cdb182899614c1b2a8..070a4f2d3a2be8e5c8acf15f509a81d014d18703:/wxPython/demo/wxTreeListCtrl.py diff --git a/wxPython/demo/wxTreeListCtrl.py b/wxPython/demo/wxTreeListCtrl.py index e5b05a9106..4015c0665f 100644 --- a/wxPython/demo/wxTreeListCtrl.py +++ b/wxPython/demo/wxTreeListCtrl.py @@ -1,26 +1,31 @@ +# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# -from wxPython.wx import * -from wxPython.gizmos import wxTreeListCtrl +import wx +import wx.gizmos as gizmos -import images +import images #---------------------------------------------------------------------- -class TestPanel(wxPanel): +class TestPanel(wx.Panel): def __init__(self, parent, log): self.log = log - wxPanel.__init__(self, parent, -1) - EVT_SIZE(self, self.OnSize) + wx.Panel.__init__(self, parent, -1) + self.Bind(wx.EVT_SIZE, self.OnSize) - self.tree = wxTreeListCtrl(self, -1, style = wxTR_DEFAULT_STYLE - #| wxTR_ROW_LINES - #| wxTR_NO_LINES | wxTR_TWIST_BUTTONS + self.tree = gizmos.TreeListCtrl(self, -1, style = wx.TR_DEFAULT_STYLE + #| wx.TR_ROW_LINES + #| wx.TR_NO_LINES + #| wx.TR_TWIST_BUTTONS ) isz = (16,16) - il = wxImageList(isz[0], isz[1]) - fldridx = il.Add(wxArtProvider_GetBitmap(wxART_FOLDER, wxART_OTHER, isz)) - fldropenidx = il.Add(wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_OTHER, isz)) - fileidx = il.Add(wxArtProvider_GetBitmap(wxART_REPORT_VIEW, wxART_OTHER, isz)) + 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)) smileidx = il.Add(images.getSmilesBitmap()) self.tree.SetImageList(il) @@ -37,8 +42,8 @@ class TestPanel(wxPanel): 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) - self.tree.SetItemImage(self.root, fldridx, which = wxTreeItemIcon_Normal) - self.tree.SetItemImage(self.root, fldropenidx, which = wxTreeItemIcon_Expanded) + self.tree.SetItemImage(self.root, fldridx, which = wx.TreeItemIcon_Normal) + self.tree.SetItemImage(self.root, fldropenidx, which = wx.TreeItemIcon_Expanded) for x in range(15): @@ -46,28 +51,43 @@ class TestPanel(wxPanel): child = self.tree.AppendItem(self.root, txt) self.tree.SetItemText(child, txt + "(c1)", 1) self.tree.SetItemText(child, txt + "(c2)", 2) - self.tree.SetItemImage(child, fldridx, which = wxTreeItemIcon_Normal) - self.tree.SetItemImage(child, fldropenidx, which = wxTreeItemIcon_Expanded) + self.tree.SetItemImage(child, fldridx, which = wx.TreeItemIcon_Normal) + self.tree.SetItemImage(child, fldropenidx, which = wx.TreeItemIcon_Expanded) 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) - self.tree.SetItemImage(last, fldridx, which = wxTreeItemIcon_Normal) - self.tree.SetItemImage(last, fldropenidx, which = wxTreeItemIcon_Expanded) + self.tree.SetItemImage(last, fldridx, which = wx.TreeItemIcon_Normal) + self.tree.SetItemImage(last, fldropenidx, which = wx.TreeItemIcon_Expanded) 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) - self.tree.SetItemImage(item, fileidx, which = wxTreeItemIcon_Normal) - self.tree.SetItemImage(item, smileidx, which = wxTreeItemIcon_Selected) + self.tree.SetItemImage(item, fileidx, which = wx.TreeItemIcon_Normal) + self.tree.SetItemImage(item, smileidx, which = wx.TreeItemIcon_Selected) self.tree.Expand(self.root) + self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) + + + def OnRightUp(self, evt): + # Convert the position from being relative to the subwindow to + # being relative to the outer treelist window so HitTest will + # have the point it is expecting. + pos = evt.GetPosition() + pos = self.tree.GetMainWindow().ClientToScreen(pos) + pos = self.tree.ScreenToClient(pos) + item, flags, col = self.tree.HitTest(pos) + + if item: + print flags, col, self.tree.GetItemText(item, col) + def OnSize(self, evt): self.tree.SetSize(self.GetSize()) @@ -86,15 +106,13 @@ def runTest(frame, nb, log): overview = """