Hi, John.  With the change, "fig = figure(figsize=(w, h))" properly creates
a figure window with a correctly-sized canvas, but "fig.set_size_inches((w,
h), forward=True)" raises

    AttributeError: 'FigureCanvasWxAgg' object has no attribute
'SetSizeFunc'

in FigureManagerWx.resize.  Previously, the SetInitialSize called by
FigureFrameWx.__init__ and FigureManagerWx.resize was an attribute of the
canvas, but the new code makes SetSizeFunc an attribute of the frame
instead.  FigureManagerWx.resize was still looking under the canvas.

Would you please look over the attached patch?  During
FigureCanvasWx.__init__, it connects FigureCanvasWx.SetInitialSize to
SetBestFittingSize or do_nothing if it isn't already inherited from
wx.Panel.  FigureFrameWx.__init__ and FigureManagerWx.resize just call
FigureCanvasWx.SetInitialSize.

Stan


-----Original Message-----
From: John Hunter [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 10, 2008 10:31
To: Stan West
Cc: Nils Wagner; matplotlib-devel@lists.sourceforge.net
Subject: Re: [matplotlib-devel] AttributeError: 'FigureCanvasWxAgg' object
has no attribute 'SetInitialSize'

On Tue, Jun 10, 2008 at 9:21 AM, Stan West <[EMAIL PROTECTED]> wrote:
> Greetings.  According to http://www.wxpython.org/recentchanges.php,
> SetInitialSize became available at version 2.7.2.0 (7 Nov 2006) of
wxPython.
> It renamed the prior SetBestFittingSize, for which I found no other 
> mention in the changes document.  (That version history lists those 
> methods as belonging to wx.Window, from which wx.Panel inherits.)

OK, I committed a change to svn using:

        def do_nothing(*args, **kwargs):
            warnings.warn('could not find a SetSizeFunc for backend_wx;
please report your wxpython version=%s to the matplotlib developers
list'%backend_version)
            pass

        # try to find the set size func across wx versions
        self.SetSizeFunc = getattr(self.canvas, 'SetInitialSize',
                                   getattr(self.canvas,
'SetBestFittingSize', do_nothing))
        self.SetSizeFunc(wx.Size(fig.bbox.width, fig.bbox.height))


Could you guys test from svn on your respective wx versions and/or check
that the logic looks correct here?

Thanks,
JDH

Attachment: backend_wx.patch
Description: Binary data

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to