|
1
0
这是我第一次听说wxlistgrid,所以我不知道它能做什么。但是,一般情况下,您总是可以捕获低级鼠标单击事件(例如
|
|
|
2
2
我搞糊涂了。您应该能够像使用任何其他小部件一样,直接绑定到evt-left-down。我刚试过,它对我有用。请参见以下示例:
MyForm类(wx.frame): def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "List Control Tutorial", size=(500,500))
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
self.index = 0
self.list_ctrl = wx.ListCtrl(panel, size=(-1,100),
style=wx.LC_REPORT
|wx.BORDER_SUNKEN
)
self.list_ctrl.InsertColumn(0, 'Subject')
self.list_ctrl.InsertColumn(1, 'Due')
self.list_ctrl.InsertColumn(2, 'Location', width=125)
self.list_ctrl.Bind(wx.EVT_LEFT_DOWN, self.onLeftClick)
btn = wx.Button(panel, label="Add Line")
btn.Bind(wx.EVT_BUTTON, self.add_line)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.list_ctrl, 0, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
def add_line(self, event):
line = "Line %s" % self.index
self.list_ctrl.InsertStringItem(self.index, line)
self.list_ctrl.SetStringItem(self.index, 1, "01/19/2010")
self.list_ctrl.SetStringItem(self.index, 2, "USA")
self.index += 1
def onLeftClick(self, event):
pos = event.GetPosition()
print str(pos)
希望有帮助。 迈克·德里斯科尔 |