如何从 wxpyton gui 点击事件获取列表数据?
我有一个列表控制框,并用数据填充它。
self.listView1.Append([sFilename,sTitle,sArtist,sAlbum,sDestDir])
我创建了一个事件,当用户单击列表中的特定项目时触发
def OnListView1ListItemSelected(self, event):
print "onListViewSelect"
这有效,但我所困惑的是如何从用户单击的列表中捕获单行数据?
I have a list ctrl box and I populate it with data.
self.listView1.Append([sFilename,sTitle,sArtist,sAlbum,sDestDir])
I created an event that triggers when a user clicks on a specific item in the list
def OnListView1ListItemSelected(self, event):
print "onListViewSelect"
This works, but what I am stuck on is how do I capture the single line of data from the list the user clicked on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 wxPython 2.8.10,这是将所选行中所有列中的文本拖放到列表中的一种方法。您将获取对象、选定的索引、列数,然后从每列中获取文本:
我提到该版本是因为我认为最新的 wxPython 版本允许您在 wx.ListCtrl.GetItemText 中指定列,这可以简化事情有点。不过我还没试过。
Using wxPython 2.8.10, this is one way to drop the text from all columns in the selected row into a list. You're getting the object, selected index, number of columns, and then grabbing the text from each column:
I mentioned the version because I think the newest wxPython release allows you to specify a column in wx.ListCtrl.GetItemText, which could simplify things a bit. I haven't tried it though.
我认为最简单的方法是将数据与行关联起来。您可以在这里阅读我的方法:
http://www.blog.pythonlibrary.org/2011/01/04/wxpython-wx-listctrl-tips-and-tricks/
就个人而言,我最喜欢ObjectListView:http://objectlistview.sourceforge.net/python/index.html
I think the simplest way is to just associate the data with the row. You can read about my approach here:
http://www.blog.pythonlibrary.org/2011/01/04/wxpython-wx-listctrl-tips-and-tricks/
Personally, I like ObjectListView the best: http://objectlistview.sourceforge.net/python/index.html