wxPython.Fit() is funky.

Discussion in 'Python' started by Tom Plunket, Jun 25, 2003.

  1. Tom Plunket

    Tom Plunket Guest

    (Is this an appropriate place to ask wxPython questions?)

    Here's some code (line breaks put in without testing them, I'm
    kinda a newbie hope they're ok):

    <busted.py>

    from wxPython.wx import *

    class MyFrame(wxFrame):
    def __init__(self, size):
    wxFrame.__init__(self, NULL, -1, "Test Window")
    self.panel = wxPanel(self, -1, size = size)
    print '\ninitial size of panel is:', \
    self.panel.GetSize(), "and the window is:", \
    self.GetSize()

    self.Fit()
    print 'after a Fit(), size of panel is:', \
    self.panel.GetSize(), "and the window is:", \
    self.GetSize()

    print '\nIf I manually set the client size, it works:'
    self.SetClientSize(size)
    print '\tsize of panel is:', self.panel.GetSize(), \
    "and the window is:", self.GetSize()

    print '\nBut isn\'t this what the Fit call is ' + \
    'supposed to do?'


    if __name__ == "__main__":
    print '\n***************************************************'
    print 'The panel should be 640x480, and the window ' +
    'should fit it tightly.'
    frame = MyFrame((640, 480))
    frame.Destroy()
    print '*****************************************************'

    ***

    Ok, so this code here, when executed in WinXP, prints different
    values after thet self.Fit() call than I want. I set the panel
    size explicitly, and then self.Fit() changes the dimensions of
    both self *and* self.panel. Why? Wouldn't the documentation
    indicate that it only changes the 'self' parameter passed in to
    Fit()? That's what it says to me:

    : wxWindow::Fit
    : virtual void Fit()
    :
    : Sizes the window so that it fits around its subwindows. This
    : function won't do anything if there are no subwindows.

    It doesn't seem to imply that child windows will be changed to do
    this fitting... Unfortunately, this behavior means that Fit() is
    nearly useless for me. I just started doing this wx and Python
    stuff, and every window that I create in my recent project needs
    to be sized based on the content. The way Fit() works is making
    me actually compute the size of the content myself. It's not
    hard, but it is tedious when the library tells you that this
    functionality is available.

    Apologies if this is off-topic (responses/flames can be directed
    straight to me if it is), and thanks for any help.

    -tom!
    Tom Plunket, Jun 25, 2003
    #1
    1. Advertising

  2. Tom Plunket

    Miki Tebeka Guest

    Hello Tom,

    > Unfortunately, this behavior means that Fit() is
    > nearly useless for me. I just started doing this wx and Python
    > stuff, and every window that I create in my recent project needs
    > to be sized based on the content. The way Fit() works is making
    > me actually compute the size of the content myself. It's not
    > hard, but it is tedious when the library tells you that this
    > functionality is available.

    Why don't you use sizers?
    (http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin40.htm#wxboxsizer)
    They save you from doing all this stuff by yourself.

    HTH.
    Miki
    Miki Tebeka, Jun 26, 2003
    #2
    1. Advertising

  3. Tom Plunket

    Tom Plunket Guest

    Miki Tebeka wrote:

    > > Unfortunately, this behavior means that Fit() is
    > > nearly useless for me.

    >
    > Why don't you use sizers?
    > (http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin40.htm#wxboxsizer)
    > They save you from doing all this stuff by yourself.


    In one case in particular, I have a panel that's the size I want,
    and I want the frame to fit neatly around it. Seems like
    overkill to use a sizer, especially when the documentation for
    Fit() implies that it does what I want.

    The panel doesn't contain any controls, and I "give" that window
    to Pygame/SDL anyway so wx loses control of it. It starts out
    the size I want.

    -tom!
    Tom Plunket, Jun 26, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Diogenes Dilone

    Funky error Situation

    Diogenes Dilone, Jan 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    516
    Diogenes Dilone
    Jan 7, 2004
  2. =?Utf-8?B?VHJhY3k=?=

    Funky address change.

    =?Utf-8?B?VHJhY3k=?=, Mar 16, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    362
    Juan T. Llibre
    Mar 16, 2006
  3. iksrazal

    funky but simple regex

    iksrazal, Jul 19, 2004, in forum: Java
    Replies:
    3
    Views:
    370
    iksrazal
    Jul 20, 2004
  4. Piet
    Replies:
    1
    Views:
    586
  5. Piet
    Replies:
    0
    Views:
    508
Loading...

Share This Page