Question about toolbar customization

I like the new file dialog that Clovis suggested for the Tk backend.

I suggest two modifications before submitting a patch:

  1. Could you add an error message when an unknown extension is given?
    Right now it does nothing, but the user should probably be warned.

  2. Could you add a warning when an existing filename is given and ask if the user wants to overwrite?

When that is added, I suggest you submit a patch.

Thanks

Mark

Message: 1

···

Date: Thu, 04 Aug 2005 11:19:50 -0300
From: Clovis Goldemberg <clovis@…713…39…>
To: matplotlib-users@…714…

orge.net
Subject: [Matplotlib-users] Question about toolbar customization

Dear all,

I have two suggestions about toolbar customization:

  1. In the ‘matplotlibrc’ file the toolbar line should be changed in
    order to include a “custom toolbar”

toolbar : toolbar2 # None | classic | toolbar2 | custom

  1. In the ‘backend_tkagg.py file’, inside the ‘NavigationToolbar2TkAgg
    class’ the
    save_figure procedure should be changed to somewhat:

    def save_figure(self):
    from tkFileDialog import asksaveasfilename

     fname = asksaveasfilename(master=self.window,
                               title='Save
    

the figure’,
filetypes=[(‘Encapsulated
Postscript
File’,‘*.eps’),

(‘Scalable Vector
Graphics’,‘*.svg’),

(‘Portable Network
Graphics’,‘*.png’)])

initialfile=InitialFilename)

    if fname == "" :
        return
    else:
        bname, fext = os.path.splitext

(fname)
if (fext.lower()==‘.png’):
self.canvas.print_figure(fname,
dpi=300)
elif (fext.lower()==‘.eps’):
self.canvas.print_figure(fname)
elif (fext.lower()==‘.svg’):
self.canvas.print_figure(fname)

I think that the asksaveasfilename function provided  by

tkFileDialog is “better”