From: Thomas R. <tho...@gm...> - 2009-04-29 03:01:32
|
Hi John, Thanks for your help! I'm not sure how I should go about overriding the existing method. Say I have the following custom savefig(): def savefig(self, evt): print "Hello world" and a figure() instance fig, how do I actually tell fig.canvas.manager.frame.toolbar.save to actually point to my custom savefig? Thanks! Thomas On 28 Apr 2009, at 11:57, John Hunter wrote: > > > On Tue, Apr 28, 2009 at 8:21 AM, Thomas Robitaille <tho...@gm... > > wrote: > Hi, > > I was wondering if it is possible to override the 'save' button in > wxAgg so that once a filename has been specified in the dialog, a > custom function is run instead of the default savefig? Maybe this > would require too much hacking? > > > You could probably override the > matplotlib.backends.backend_wx.NavigationToolbar2.save function. If > you are using pylab/pyplot, this function is accessible as > > In [3]: fig.canvas.manager.frame.toolbar.save > Out[3]: <bound method NavigationToolbar2WxAgg.save of > <matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg; proxy of > <Swig Object of type 'wxToolBar *' at 0x3b5bc60> >> > > and has the signature:: > > def save(self, evt): > > where evt is the GUI event that generated the callback (can safely > be ignored). > > If you are embedding mpl in wx directly, you can create your own > toolbar as in the embedding_in_wx* examples at > > http://matplotlib.sourceforge.net/examples/user_interfaces/ > index.html > > JDH |