close-event

Hi all,

I want to use matplotlib to plot in realtime the position of a microscope stage, read out over a serial connection. Essentially I reached my goal, starting from the example simple_idle_wx.py http://matplotlib.sourceforge.net/examples/animation/simple_idle_wx.html

Now I have two questions

1) I would like to stay independent of the backend, therefore I would prefer a approach like in idle_and_timeout http://matplotlib.sourceforge.net/examples/event_handling/idle_and_timeout.html
However, with my default backend WXAgg I do not continuously idle events, but only once e.g. after each mouse movement. Can someone give me more information about the intended behaviour, current status and support of idle events?

2) I want to limit the lifetime of my connection object, that takes care of the communication with the microscope stage, so that the connection is closed if I close the matplotlib figure. I could not find a 'close_event'. To achieve this I could embed a matplotlib figure into a wx frame, but this is somewhat tediuos. For the wxagg backend, does somebody know a more simple solution? Do others also feel the need to add a close_event? In case, I could try to take care of the wx backend.

Gregor

1) I would like to stay independent of the backend, therefore I would
prefer a approach like in idle_and_timeout
http://matplotlib.sourceforge.net/examples/event_handling/idle_and_timeout.html
However, with my default backend WXAgg I do not continuously idle
events, but only once e.g. after each mouse movement. Can someone give
me more information about the intended behaviour, current status and
support of idle events?

I worked on this for a while and thought I had wx working but maybe I
missed something or maybe there is a wx version issue. The real
stumbling block was tk since it did not have a native idle and I was
stuck trying to make it work with threading. In and of itself, this
was OK, but it broke CTRL-C in ipython due to problems with cross
thread signal handling. So I put the project on the back burner.

Perhaps we can borrow some knowledge from the ipython developers who
have recently made good progress here in various GUIs backends.

2) I want to limit the lifetime of my connection object, that takes care
of the communication with the microscope stage, so that the connection
is closed if I close the matplotlib figure. I could not find a
'close_event'. To achieve this I could embed a matplotlib figure into a
wx frame, but this is somewhat tediuos. For the wxagg backend, does
somebody know a more simple solution? Do others also feel the need to
add a close_event? In case, I could try to take care of the wx backend.

Adding a close event at the mpl level should be fairly
straight-forward, and shouldn't require much if any additional GUI
programming since we already handle the window destroy event across
backends for pylab figure management.

JDH

···

On Fri, Nov 13, 2009 at 10:39 AM, Gregor Thalhammer <Gregor.Thalhammer@...2860...> wrote:

Well, yes, that is how wx idle events work. I have no idea how any other toolkits do idle events. As a result, I've found that I never use EVT_IDLE with wx -- it just isn't useful, you get a whole bunch of them when someone is doing something like moving the mouse slowly, and none when the user is doing nothing.

What I have done is use a wx.Timer instead -- if you want something to happen when the user isn't doing anything, you can start a timer, and have it fire whenever you want. You can also have the timer started by an IDLE event, and have each subsequent IDLE event

I don't know if MPL has a Timer that wraps the GUI toolkit timers, but that may be a good idea.

-Chris

···

On Fri, Nov 13, 2009 at 10:39 AM, Gregor Thalhammer > <Gregor.Thalhammer@...2860...> wrote:

1) I would like to stay independent of the backend, therefore I would
prefer a approach like in idle_and_timeout
http://matplotlib.sourceforge.net/examples/event_handling/idle_and_timeout.html
However, with my default backend WXAgg I do not continuously idle
events, but only once e.g. after each mouse movement. Can someone give
me more information about the intended behaviour, current status and
support of idle events?

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...