如何检测在使用gizmo创建的TreeList中单击了哪个列。以下代码检测到标签区域单击,但我无法获取单击的列。
import wx.gizmos
class MyGizmos(wx.gizmos.TreeListCtrl):
def __init__(self, parent):
super(MyGizmos, self).__init__(parent)
self.AddColumn('vars')
self.AddColumn('vals')
self.SetColumnWidth(0, 100)
self.SetColumnWidth(1, 100)
root = self.AddRoot('foodata')
self.SetItemText(self.AppendItem(root, 'var 1'), 'val 1', 1)
self.Bind(wx.EVT_LIST_COL_CLICK, self.OnLabel)
def OnLabel(self, event):
print 'col label clicked, but which one ???'
item = event.GetItem()
print item # prints wx._controls.ListItem
print item.GetColumn() # always 0
#print item.GetColumn(0) # fails
class _demo_Frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='gizmos label click')
self.tree = MyGizmos(self)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = _demo_Frame()
frame.Show()
app.MainLoop()