wx._core.PyAssertionError: C++ assertion "GetCapture() == this" failed at ..\..\src\common\wincmn.cpp(2536) in wxWindowBase::ReleaseMouse(): attempt to release mouse, but this window hasn't captured it
File "c:\mldStuff\Profile\My Documents\My Dropbox\Scripts\wx tutorials\buttons\shapedBtnDemo.py", line 82, in <module>
File "c:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 8007, in MainLoop
File "c:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7303, in MainLoop
return _core_.PyApp_MainLoop(*args, **kwargs)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\shapedbutton.py", line 1301, in OnLeftUp
File "c:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 9741, in ReleaseMouse
return _core_.Window_ReleaseMouse(*args, **kwargs)
The ReleaseMouse call should be guarded with a HasCapture check. Its
throwing an assertion since the window doesn't have the capture.
On Wed, Jun 9, 2010 at 6:36 PM, Mike Driscoll <mi...@pythonlibrary.org> wrote:
> Are you saying I need to implement this functionality? I looked at the
> ShapedButton's code and it looks like it has a HasCapture check in the
> OnLeftUp method (lines 1066-1076).
No, sorry I should have been more clear. If thats the case its a bug
in the control. It should release the mouse capture before sending its
event. The error is happening because it is dispatching another event
with its Notify() method while still in the context of handling the
mouse event. So its notify will cause your event handler to execute
at which point the control will loose the mouse capture when you show
your dialog. Then when control returns to the event handler after
Notify and it calls ReleaseMouse it no longer has the capture.
A patch would be to move
if self._isup != self._saveup:
after the ReleaseMouse call in shapedbutton.py.
A workaround in your code would be to do a CallAfter to show the dialog.
The problem is probably that the button is sending the event before it
does the release. So yes, it is checking that it still has the capture,
but then your event handler is being called and showing the dialog will
cause the capture to be lost, and then when it gets back to OnLeftUp it
is trying to release the capture it no longer has. Please test moving
the release to before the if statement that results in self.Notify being