I’m using wx.lib.buttons.GenButton and a very slow running Linux machine (Centos5 or Centos7, not sure which) showed up some odd problems that wouldn’t normally appear. I’ve subclassed GenButton to get round them, but thought the info might be useful. I’m using wxPython 3.0.2.0 with Python 2.7 but checked the source for 4.0.4 and the relevant bits appear to be the same.
On occasion, a traceback was recieved from a click on the button:
Traceback (most recent call last):
File "/usr/local/wxPython-src-3.0.2.0/wxPython/wx/lib/buttons.py", line 330, in OnLeftDown
File "/usr/local/wxPython-src-3.0.2.0/wxPython/wx/_core.py", line 10638, in CaptureMouse
wx._core.PyAssertionError: C++ assertion "!wxMouseCapture::IsInCaptureStack(this)" failed at ../src/common/wincmn.cpp(3271) in CaptureMouse(): Recapturing the mouse in the same window?
I overrode OnLeftDown and added
if self.HasCapture():
return
before calling the GenButton OnLeftDown.
On a separate run a traceback complained that EVT_MOUSE_CAPTURE_LOST wasn’t being handled. I bound this to an OnCaptureLost method but wasn’t sure what the action should be, so guesed that you’d want the button to appear in its normal state and used:
def OnCaptureLost(self, evt):
""" OnCaptureLost: if mouse capture lost, put button back to "up" state """
self.up = True
self.Refresh()