wx.EVT_LEFT_UP doesn't work right in Windows 7 or XP

I have an app that displays several custom buttons that have 3 methods bound to itself:

class ItemButton(wx.Button):

def init(self, parent, id=-1, label=""):

self.parent = parent

wx.Button.init(self, parent, label=str(label), size=(125,125), style=wx.BORDER_NONE)

self.set_default_bg()

self.selected = False

wx.EVT_RIGHT_DOWN(self, self.begin_tx)

wx.EVT_RIGHT_UP(self, self.end_tx)

wx.EVT_LEFT_UP(self, self.select_for_primary)

Now, on OSX, If I left-click on the button, the event fires, and all is great.

Windows is a different story.

I can click once with no problem. However after that initial click, clicking anywhere in the app does nothing. The window can’t be moved, the menus cannot be used, in fact the event hander for the button just clicked fires every time I click no matter where I click in the window – that is, the application acts like I’ve not moved my cursor at all. It is “stuck” until I change to another app and then back to it e.g. alt-tab to Chrome and then back to the app. Once that happens, the app becomes completely responsive.

I’ve got a background thread that’s doing some serial communications and the event that is firing off does talk to that controller. However, the other two right-click events do the same thing, and they do not cause this problem.

Also noticed that this line:

wx.EVT_LEFT_UP(self, self.select_for_primary)

is changed to:

self.Bind(wx.EVT_BUTTON, self.select_for_primary)

Then there is no problem and the GUI works 100% as expected. No alt-tabbing required. Is this a bug, or should EVT_LEFT_UP not be used in this way?

Will gladly submit a demo app if requested.

I’ve never seen this way:
wx.EVT_LEFT_UP(self, self.select_for_primary)

I’ve seen this way a lot:

yourFrameOrPanelObject.Bind(wx.EVT_BUTTON, self.select_for_primary, yourButtonObjectReference)

and also this way

yourButtonObjectReference.Bind(wx.EVT_BUTTON, self.select_for_primary)

···

On Thursday, August 21, 2014 9:57:11 PM UTC-7, Nick Vahalik wrote:

I have an app that displays several custom buttons that have 3 methods bound to itself:

class ItemButton(wx.Button):

def init(self, parent, id=-1, label=“”):

self.parent = parent

wx.Button.init(self, parent, label=str(label), size=(125,125), style=wx.BORDER_NONE)

self.set_default_bg()

self.selected = False

wx.EVT_RIGHT_DOWN(self, self.begin_tx)

wx.EVT_RIGHT_UP(self, self.end_tx)

wx.EVT_LEFT_UP(self, self.select_for_primary)

Now, on OSX, If I left-click on the button, the event fires, and all is great.

Windows is a different story.

I can click once with no problem. However after that initial click, clicking anywhere in the app does nothing. The window can’t be moved, the menus cannot be used, in fact the event hander for the button just clicked fires every time I click no matter where I click in the window – that is, the application acts like I’ve not moved my cursor at all. It is “stuck” until I change to another app and then back to it e.g. alt-tab to Chrome and then back to the app. Once that happens, the app becomes completely responsive.

I’ve got a background thread that’s doing some serial communications and the event that is firing off does talk to that controller. However, the other two right-click events do the same thing, and they do not cause this problem.

Also noticed that this line:

wx.EVT_LEFT_UP(self, self.select_for_primary)

is changed to:

self.Bind(wx.EVT_BUTTON, self.select_for_primary)

Then there is no problem and the GUI works 100% as expected. No alt-tabbing required. Is this a bug, or should EVT_LEFT_UP not be used in this way?

Will gladly submit a demo app if requested.