The Problem:
It seems like one event is disabling another event. Before calling event B, event A works just fine. After event B fires, event A no longer works. Both events are custom ones that people made for their wxPython libraries (FloatCanvas and ColourSelect). I'd like to trace the generated events to make sure that, after event B, event A is still being fired (but perhaps not triggering the handler code?)
The Details:
I have a wxPython app where I create a wx.Panel
object with two child items - a plot and a legend. This top level panel handles the majority of the events.
The plot is a
wx.Panel
object with a singlewx.lib.FloatCanvas.FloatCanvas
canvas in it.The legend is a
wx.Panel
with multiplewx.StaticText
andwx.lib.colourselect.ColourSelect
objects in it (I'm plotting discrete data points).
On the plot, I bind FloatCanvas.EVT_MOUSEWHEEL
to my zoom in/out function. On the legend, I bind the wx.lib.colourselect.EVT_COLOURSELECT
event to my update_colors function which then sends the event to the parent panel via wx.PostEvent(event)
.
The parent panel then receives EVT_COLOURSELECT
from the child and executes code that changes the colors of my plots.
Source Code:
I haven't had time to write a small sample that demo's the problem, but you can see the problem by running the source code: https://github.com/dougthor42/wafer_map
Run the wm_app.py file and then go through the following test steps.
Testing Steps:
- Scroll/zoom in and out - works just fine
- Change a plot color (fires
EVT_COLOURSELECT
). If you're testing with the source code you do this by clicking on a legend color box and choosing a new color. - Attempt to zoom in and out again. Doesn't work!
- Verify that all other events (key down, click-and-drag, mouse move) all work.
Things I've Tried:
Obviously these didn't work or else I wouldn't be here :-P
Unbinding the mousewheel event and rebinding it when the top level panel receives the event from the child.
Completely disabling the handlers for
EVT_COLOURSELECT
in both the parent panel and the legend.- I thought that perhaps there was something going on in my handlers. Turns out, just
triggering
EVT_COLOURSELECT
causes theEVT_MOUSEWHEEL
to stop working.
- I thought that perhaps there was something going on in my handlers. Turns out, just
triggering
Changing
FloatCanvas.EVT_MOUSEWHEEL
to some other event, for exampleFloatCanvas.EVT_RIGHT_DOWN
- This does actually work! I loose the 'speed' info from the mouse wheel, but right-clicking before and after step 2 both work.
- Seems to indicate that it's an issue with the mouse scroll event specifically.
Has anyone had a problem where events interfere with each other?