I think now is a good time to start implementing some GUI neutral
event handling and wanted to bounce some ideas off the list. The idea
is for matplotlib to define its own event handler in matplotlib.events
and each of the GUIs trigger these events. Users could register with
the event handler using an observer pattern. In user space, you could
do something like the following and expect it to work across Tk, Wx
import matplotlib.events as events
Each of the GUIs would call matplotlib.events.notify. The backends
would have to map the GUI constants, eg LEFT_BUTTON, to the
appropriate matplotlib.event constant and handle things like flip y
inversion since the matplotlib coordinate system is 0,0 = lower, left.
This would also lay the groundwork for generalizing things like
examples/object_picker.py, writing generic measure tools, and so on.
You could write a GUI neutral axes resize tool where the user could
click on an axes and drag the size. So it would be useful for the
users who want to define some GUI interaction and or the developers
who want to add features across backends w/o having to know all the
My questions are
* Does this look like a good framework?
* Does someone want to implement the interface matplotlib.events?
* Do the GUI maintainers for Tk (Todd), Wx (Jeremy) and GTK (Me)
have time to do the mapping? If not can we get another volunteer?
* What events do we want to define? The ones I use a lot are::
If these basic events are implemented at the backend level, we
could catch them and trigger more complicated events like
'drag_rectangle' in matplotlib.events. Ie, catch press, mouse
move, and release, and then trigger drag_rectangle with start and
end locations in event.start and event.end.
* There is the issue of coords. x, y can be given in data, axes
(0-1) or data coords. Probably best to give all three
See examples/coords_demo_gtk.py for an example of connecting to a
GTK event and mapping the display coords to data space. Jeremy
and Todd, this would be a good example to implement as stage 1 for
the event handling.
Of course, there is no end to how far you could go with this, defining
a basic cross GUI widget API for dialog boxes, entry boxes and so on.
A meta-wx, if you will. But that is an issue for another day.