'remote control' matplotlib window

I have a question, how to control matplotlib from another application.

Let me explain. We want to monitor some sensor data. The monitoring application already offers a toolbar to choose the view for several embedded windows. For example, buttons like “Reset view”,“Back/Forward”, “Pan”, “Zoom” and many more are available. The same functions that are shown in each TkAgg matplotlib window (like the six buttons in the bottom of http://postneo.com/pix/matplotlib.png, for example).

Because we don’t want to duplicate the buttons, we want to

  • Hide the buttons in the matplotlib window
  • Show only the plot without any decorations
  • Embed the matplotlib window into out wxPython application (this step
    is nice-to-have, but we can also work with another toplevel window, which is not embedded)
  • Finally, but most important: control from our wxPython application when to set the matplotlib window into Zoom/Pan/Rotate mode

How can we implement the last step? Do we have to implement our own Backend? What we need is documented for Chaco in detail, but has it been done with matplotlib before? We prefer matplotlib because it is more advanced except for the UI integration.

Please guide us in the right direction
Peter

See the embedding_in_wx examples at
http://matplotlib.sourceforge.net/examples/user_interfaces/index.html.
Take a look at the source code in matplotlib/backend_bases.py at the
NavigationToolbar2 implementation to see how we manage the pan/zoom
state, etc....

JDH

···

On Tue, Nov 17, 2009 at 1:51 PM, Peter McGregor <petermcgregor23@...9...> wrote:

I have a question, how to control matplotlib from another application.

Let me explain. We want to monitor some sensor data. The monitoring
application already offers a toolbar to choose the view for several embedded
windows. For example, buttons like "Reset view","Back/Forward", "Pan",
"Zoom" and many more are available. The same functions that are shown in
each TkAgg matplotlib window (like the six buttons in the bottom of
http://postneo.com/pix/matplotlib.png, for example).

Because we don't want to duplicate the buttons, we want to
* Hide the buttons in the matplotlib window
* Show only the plot without any decorations
* Embed the matplotlib window into out wxPython application (this step is
nice-to-have, but we can also work with another toplevel window, which is
not embedded)
* Finally, but most important: control from our wxPython application when to
set the matplotlib window into Zoom/Pan/Rotate mode

How can we implement the last step? Do we have to implement our own Backend?
What we need is documented for Chaco in detail, but has it been done with
matplotlib before? We prefer matplotlib because it is more advanced except
for the UI integration.

Thanks for your reply, but:

See the embedding_in_wx examples at
http://matplotlib.sourceforge.net/examples/user_interfaces/index.html.

The problem with those examples is, when I comment the following line (for example in http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_wx2.html):

        self.add_toolbar() # comment this out for no toolbar

then I have no possibility to make the window react to mouse events.

Take a look at the source code in matplotlib/backend_bases.py at the
NavigationToolbar2 implementation to see how we manage the pan/zoom
state, etc....

I see how the states are handled in NavigationToolbar2. But this would require that I rewrite the complete event handler. Or how do I tell the NavigationToolbar2 "You are now in pan state. Wait for the next mouse button press and then start panning the window."?

Thank you
Peter

···

________________________________
Von: John Hunter <jdh2358@...287...>
An: Peter McGregor <petermcgregor23@...9...>
CC: matplotlib-users@lists.sourceforge.net
Gesendet: Dienstag, den 17. November 2009, 22:25:42 Uhr
Betreff: Re: [Matplotlib-users] 'remote control' matplotlib window

On Tue, Nov 17, 2009 at 1:51 PM, Peter McGregor <petermcgregor23@...9...> wrote:

I have a question, how to control matplotlib from another application.

Let me explain. We want to monitor some sensor data. The monitoring
application already offers a toolbar to choose the view for several embedded
windows. For example, buttons like "Reset view","Back/Forward", "Pan",
"Zoom" and many more are available. The same functions that are shown in
each TkAgg matplotlib window (like the six buttons in the bottom of
http://postneo.com/pix/matplotlib.png, for example).

Because we don't want to duplicate the buttons, we want to
* Hide the buttons in the matplotlib window
* Show only the plot without any decorations
* Embed the matplotlib window into out wxPython application (this step is
nice-to-have, but we can also work with another toplevel window, which is
not embedded)
* Finally, but most important: control from our wxPython application when to
set the matplotlib window into Zoom/Pan/Rotate mode

How can we implement the last step? Do we have to implement our own Backend?
What we need is documented for Chaco in detail, but has it been done with
matplotlib before? We prefer matplotlib because it is more advanced except
for the UI integration.

See the embedding_in_wx examples at
http://matplotlib.sourceforge.net/examples/user_interfaces/index.html.
Take a look at the source code in matplotlib/backend_bases.py at the
NavigationToolbar2 implementation to see how we manage the pan/zoom
state, etc....

JDH

Peter McGregor wrote:

The problem with those examples is, when I comment the following line (for example in http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_wx2.html):

        self.add_toolbar() # comment this out for no toolbar

then I have no possibility to make the window react to mouse events.

Give wxMPL a try:

http://agni.phys.iit.edu/~kmcivor/wxmpl/

It handles some, if not all, of this for you.

However, you bring up a good point, unless you have missed something -- the code for the various interactive modes really should be separate from the toolbar that activates those modes.

-Chris

···

--
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...

Well, they are -- they all reside in the baseclass which the GUI
toolbars override. Peter can subclass
backend_bases.NavigationToolbar2 and make a custom toolbar. If a "is
a" relation doesn't work for him, with a little work he should be able
to do a "has a" with the baseclass.

JDH

···

On Tue, Nov 17, 2009 at 4:04 PM, Christopher Barker <Chris.Barker@...259...> wrote:

Peter McGregor wrote:

The problem with those examples is, when I comment the following line (for example in http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_wx2.html):

    self\.add\_toolbar\(\) \# comment this out for no toolbar

then I have no possibility to make the window react to mouse events.

Give wxMPL a try:

http://agni.phys.iit.edu/~kmcivor/wxmpl/

It handles some, if not all, of this for you.

However, you bring up a good point, unless you have missed something --
the code for the various interactive modes really should be separate
from the toolbar that activates those modes.