mpl events

Hi, I'm working on GUI apps using matplotlib's class library

    > with both WXAgg and TkAgg backends, and am having a
    > love/hate relationship with the FigureCanvase.mpl_connect()
    > methods. These return a platform-neutral, matplotlib-aware
    > Event, which is great for dealing with the Plot canvas, but
    > swallow the native GUI event, complicating working with the
    > GUI toolkit.

Hmm, I thought the point of doing the Skip call

    def _onKeyDown(self, evt):
        """Capture key press."""
        key = self._get_key(evt)
        evt.Skip()
        FigureCanvasBase.key_press_event(self, key)

would be to prevent the event from being swallowed. So you should be
able to get those events if you've made a second connection, right?

If so, what you are arguing for is the ability to get the GUI event
within the mpl event because this is more convenient than making two
connections. Is that right?

You can always make the change with guiEvent=None in the
__init__function so other backends can add it when/if they want it.
It looks like a good idea to me to add it across backends, though.

JDH

Hi John,

Hmm, I thought the point of doing the Skip call

    def _onKeyDown(self, evt):
        """Capture key press."""
        key = self._get_key(evt)
        evt.Skip()
        FigureCanvasBase.key_press_event(self, key)

would be to prevent the event from being swallowed. So you should be
able to get those events if you've made a second connection, right?

If so, what you are arguing for is the ability to get the GUI event
within the mpl event because this is more convenient than making two
connections. Is that right?

Yes, it's a matter of convenience. What isn't? If the mpl
event include the GUI event, you can define one MyKeyDown
method, bind it once with
   canvas.mpl_connect('key_press_event',MyKeyDown)

and have it handle the whole event. To me, this seems cleaner
and easier than having two separate bindings and event handlers
for the mpl and GUI events. I've been doing this, and it's sort
of ugly to have that many event handlers.

I might be the only one who cares, but I'm binding right-click
over the canvas to show a pop-up menu. I'd like to have similar
functionality in both WX and Tk (WX for new code, but Tk for
legacy apps that currently use Pmw/Blt.graph), and am hoping for
as much overlapping code as possible.

You can always make the change with guiEvent=None in the
__init__function so other backends can add it when/if they want it.
It looks like a good idea to me to add it across backends, though.

Using guiEvent=None in the __init__() is my intention. In fact,
I believe I have this implemented for backend_bases.py,
backend_wx.py, backend_tkagg.py, and backend_gtk.py. I could
not quite figure out how to do this in backend_fltkagg.py or
backend_qtagg.py (any pointers??). I haven't had time to
adequately test this with all event types on wx/tk, and will
probably not get a chance to do so until early next week.
Again, it's all small changes, basically adding
',guiEvent=guiEvent/None/event/evt' to many argument lists.

--Matt

PS: FWIW, I see a noticeable speed increase with WXAgg on Mac
OSX from matplotlib-0.71 to the cvs version. Excellent!!