Hello wxpython-users,
Have you ever experienced some crash when using CaptureMouse() with wxPython ?
With the attached file : If you click down on the Red Rectangle, and then move away the mouse to the Windows taskbar, and release the mouse
up
there, then there is a crash !
(Do it twice, 3 times … or maximum 5 times, you will probably have a crash, at least on Windows 7).
Remark : if you remove line #14 or line #13, no more crash : this proves that the problem comes when 2 events are bound to an object (the problem is not there when only 1 event is bound to the object).
Do you have an idea ?
Best, J
___ CODE ___
import wx
from wx.lib.floatcanvas import FloatCanvas
class TestFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.canvas =FloatCanvas.FloatCanvas(self, BackgroundColor = "DARK SLATE BLUE")
MainSizer = wx.BoxSizer(wx.VERTICAL)
MainSizer.Add(self.canvas, 4, wx.EXPAND)
self.SetSizer(MainSizer)
self.canvas.Bind(FloatCanvas.EVT_LEFT_DOWN, self.OnLeftDown)
A = self.canvas.AddRectangle((10,10), (100, 20), FillColor="red")
A.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.OnRectDown)
A.Bind(FloatCanvas.EVT_FC_LEFT_UP, self.OnRectUp) # Comment this line, no more crash
wx.CallAfter(self.canvas.ZoomToBB)
def OnLeftDown(self, event):
print 'Left Button down clicked at:', event.Coords
def OnRectDown(self, event):
print 'Rectangle: Left Button down clicked at:', event.HitCoords
self.canvas.CaptureMouse()
def OnRectUp(self, event):
print 'Rectangle: Left Button up clicked at:', event.HitCoords
if self.canvas.HasCapture():
self.canvas.ReleaseMouse()
app = wx.App(0)
frame = TestFrame(None, title = “Mouse Event Tester”)
frame.Show(True)
app.MainLoop()
capturemouse_bug.py (1.26 KB)