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 
> <thomas.robitai...@gmail.com 
> > 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


------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to