Hi everyone,
I'm developing a simple GUI tool in Matplotlib that relies on the
event framework to handle buttons/sliders. I am trying to avoid using
a GUI toolkit directly to ensure maximum compatibility for users.
One thing I would like is to be able to have a 'save' button that will
open up a standard 'save file' dialog window (but not necessarily the
plot itself). Matplotlib already has 'save file' GUI dialogs for the
different backends, so I was wondering whether there is an easy and
abstract way of asking matplotlib to open a 'save file' dialog and
capturing the output? Or is this all handled separately in the
different backends?
Thanks!
Tom
Hey Tom,
It looks like the only backend-agnostic file save function is save_figure() (a toolbar method), which conflates choosing a filename and doing the actual saving. The backend-specific code to choose a filename via a dialog isn’t uniform:
Qt4:
matplotlib.backends.backend_qt4._getSaveFileName
MacOS
matplotlib.backends.backend_osx._macosx.choose_save_file
Wx:
A bunch of code in matplotlib.backends.backend_wx.save_figure
TkAgg:
Tkinter.FileDialog
GtkAgg:
get_filechooser().get_filename_from_user()
It looks like, at a minimum, you would have to write your own wrapper code to make a backend-agnostic interface for choosing a filename. Of course, if you did that, it would also be nice to refactor that into MPL itself…
chris
···
On Fri, Jun 20, 2014 at 8:22 AM, Thomas Robitaille <thomas.robitaille@…287…> wrote:
Chris Beaumont
Senior Software Engineer
Harvard Center for Astrophysics
60 Garden Street, MS 42
Cambridge, MA 02138
chrisbeaumont.org
Hi everyone,
I’m developing a simple GUI tool in Matplotlib that relies on the
event framework to handle buttons/sliders. I am trying to avoid using
a GUI toolkit directly to ensure maximum compatibility for users.
One thing I would like is to be able to have a ‘save’ button that will
open up a standard ‘save file’ dialog window (but not necessarily the
plot itself). Matplotlib already has ‘save file’ GUI dialogs for the
different backends, so I was wondering whether there is an easy and
abstract way of asking matplotlib to open a ‘save file’ dialog and
capturing the output? Or is this all handled separately in the
different backends?
Thanks!
Tom
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
](matplotlib-users List Signup and Options)