Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 wx.ListBox选择事件_Python 2.7_Wxpython - Fatal编程技术网

Python 2.7 wx.ListBox选择事件

Python 2.7 wx.ListBox选择事件,python-2.7,wxpython,Python 2.7,Wxpython,我正在使用wx.Python在MacOS下开发GUI 让我抓狂的小部件是一个简单的列表框。这是一个例子 self.values = wx.ListBox(self, wx.ID_ANY, style = wx.LB_MULTIPLE|wx.LB_NEEDED_SB) self.Bind(wx.EVT_LISTBOX, self.on_add_selection_values, self.values) 问题是,当我执行多行选择时(按住shift按钮时单击一次),它会生成多时间EVT_列表框 如

我正在使用wx.Python在MacOS下开发GUI

让我抓狂的小部件是一个简单的列表框。这是一个例子

self.values = wx.ListBox(self, wx.ID_ANY, style = wx.LB_MULTIPLE|wx.LB_NEEDED_SB)
self.Bind(wx.EVT_LISTBOX, self.on_add_selection_values, self.values)
问题是,当我执行多行选择时(按住shift按钮时单击一次),它会生成多时间EVT_列表框

如何解决这个问题

问候

  Hover over first item
  Depress left mouse button
  Drag across all itemms
  Release mouse button
这就是您选择项目的方式吗?(你提到MAC,它似乎对如何使用鼠标有自己的奇怪想法)

如果是,我建议:

Ignore the wxEVT_COMMAND_LISTBOX_SELECTED event.
Handle the mouse button up event wxEVT_LEFT_UP by calling GetSelections()

谢谢你的回答,鼠标按键事件将在我点击鼠标的任何时候启动。这会是个问题,你不这么认为吗?为什么会是个问题。如果没有选择,则GetSelections()将返回零,您的hasndler可以退出。这是因为在框架中,我有其他小部件,并且在GetSelections()之后启动的处理有点繁重,因此我不希望不必要地启动它。我不明白。当用户单击列表框时,将启动事件处理程序。如果未选择任何内容,则会立即返回。否则,这是必要的!这就是为什么它让我发疯的原因!也许我在处理macOs的一个特点。我希望当我选择第一个项目时,当我拖动项目并释放按钮时,它会启动一个事件。