[英]How can I detect an "unClick" in wxPython?
I want to detect the difference of position between when I left-click in a panel and when I finish clicking (when the left button goes up after the click).我想检测左键单击面板和完成单击之间的位置差异(单击后左键向上时)。 I detect correctly the click and I know how to get the position of the mouse but I don't know how to detect when the click ends This is how I associate the event of the left-click to the panel:
我正确检测到点击,我知道如何获取鼠标的位置,但我不知道如何检测点击何时结束这就是我将左键单击事件与面板相关联的方式:
x = wx.Panel(self, wx.ID_ANY)
x.SetBackgroundColour(wx.Colour(self.colores[aux2[1]]))
x.SetMinSize((20,20))
x.Bind(wx.EVT_LEFT_DOWN, self.onClick)
This is the event handler:这是事件处理程序:
def onClick(self, event):
if (self.modo == 'jugando'):
print('click')
And this is the output of the program:这是程序的输出:
click
So I know that I enter correctly in the handler but I don't know how can I detect when the left button of the mouse goes up afther this所以我知道我在处理程序中输入正确,但我不知道如何检测鼠标左键何时上升
I would do it this way:我会这样做:
x = wx.Panel(self, wx.ID_ANY)
x.SetBackgroundColour(wx.Colour(self.colores[aux2[1]]))
x.SetMinSize((20,20))
x.Bind((wx.EVT_MOUSE_EVENTS, self.onMouseEvent)
Event handling:事件处理:
def onMouseEvent(self, event):
if event.LeftDown():
self.previous_position = event.Position
elif event.LeftUp():
self.current_position = event.Position
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.