Frame will not resize- from Sizers Tutorial

65 views
Skip to first unread message

cappy2112

unread,
Sep 21, 2011, 3:05:32 PM9/21/11
to wxpytho...@googlegroups.com

I'm using Mike Driscoll's sizer tutorial from here
http://www.blog.pythonlibrary.org/2008/05/18/a-wxpython-sizers-tutorial/

I've modified the call to wxFrame.__init__() by adding a size parameter, as in
wx.Frame.__init__(self, None, wx.ID_ANY, title='My Form', size=(600, 380))

the frame will not resize to the size value though.

What else needs to be done to make the window resize to these values?

Attached is the entire runnable file.


Copy of driscoll_sizers_tut.py

Cody

unread,
Sep 21, 2011, 3:11:28 PM9/21/11
to wxpytho...@googlegroups.com
Hi,

Remove the 'topSizer.Fit(self)' call at the end of __init__.

The base class is initialized to 600x380 then after that the Fit call
is resizing the frame. To fit the panels contents.


Regards,

Cody

Tony Cappellini

unread,
Sep 21, 2011, 3:15:44 PM9/21/11
to wxpytho...@googlegroups.com
> Remove the 'topSizer.Fit(self)' call at the end of __init__.
>
> The base class is initialized to 600x380 then after that the Fit call
> is resizing the frame. To fit the panels contents.

Thanks.
It's working fine now

Mike Driscoll

unread,
Sep 21, 2011, 5:08:30 PM9/21/11
to wxpytho...@googlegroups.com
Huh. I'm surprised I used Fit() in my tutorial. I almost never use it in my own code. I think it's time to write a new tutorial. I'm glad Cody was able to help you though.

- Mike

Tony Cappellini

unread,
Sep 21, 2011, 5:59:20 PM9/21/11
to wxpytho...@googlegroups.com
I've always been confused when to use it vs when not to.
Based on Cody's reply, and yours below, I probably shouldn't

> --
> To unsubscribe, send email to wxPython-user...@googlegroups.com
> or visit http://groups.google.com/group/wxPython-users?hl=en

Mike Driscoll

unread,
Sep 21, 2011, 7:34:25 PM9/21/11
to wxpytho...@googlegroups.com


On Wed, Sep 21, 2011 at 4:59 PM, Tony Cappellini <capp...@gmail.com> wrote:
I've always been confused when to use it vs when not to.
Based on Cody's reply, and yours below, I probably shouldn't

Yeah, it's a weird one. I think you only want it when you want your widgets to "fit" in the frame at their minimum respective sizes. But I found I rarely wanted that and it seemed I ended up with weird issues doing it enough times that I just stopped using it. That tutorial of mine was based on something I read of Robin's (probably his book) and I thought it was cool at the time. It can still be handy, but if I'm doing a complex layout, I skip it.

-----------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org

Cody

unread,
Sep 21, 2011, 7:43:27 PM9/21/11
to wxpytho...@googlegroups.com
Hi,

Not saying there is right way or not but as matter of practice to
setup the initial layout I tend to call SetInitialSize() on the top
level container, this also allows you to set the minimum 'best' size.

Cody

Reply all
Reply to author
Forward
0 new messages