sizer help

I am trying to make my first wxpython application and I've run into a
problem trying to get the sizers to work.

Right now I just have 3 files. They are all located at

www.zcentric.com/~mike/wx

You can view those to get an overview of the app if needed. I will just
post the class in question in this email.

Now I think I have the sizers setup correctly, but I get all of the text
in the upper left and it all overlays.

Thanks
Mike

from wxPython.wx import *

class torrentFrame(wxScrolledWindow):
  def __init__(self, parent, fileName, id = -1, size = wxDefaultSize):
    wxScrolledWindow.__init__(self, parent, id, wxPoint(0, 0), size,
wxSUNKEN_BORDER)

    text = wxStaticText(self, -1, fileName, (200, 150))

    sizer = wxFlexGridSizer(cols = 8, vgap = 0)
    sizer.AddGrowableCol (0)

    fileDetails = wxStaticText(self, -1, 'Details')
    sizer.Add(fileDetails, 0, wxALIGN_BOTTOM)

    sizer.Add(wxStaticText(self, -1, ' '))

    test2 = wxStaticText(self, -1, 'Test')
    sizer.Add(test2, 0, wxALIGN_BOTTOM)
    sizer.Add(wxStaticText(self, -1, ' '))

    test3 = wxStaticText(self, -1, 'Test2')
    sizer.Add(test3, 0, wxALIGN_BOTTOM)
    sizer.Add(wxStaticText(self, -1, ' '))

    exitText = wxStaticText(self, -1, 'Exit',)
    sizer.Add(exitText, 0, wxALIGN_BOTTOM)

Hi Mike,

I am trying to make my first wxpython application and I've run into a
problem trying to get the sizers to work.

Right now I just have 3 files. They are all located at

www.zcentric.com/~mike/wx

You can view those to get an overview of the app if needed. I will just
post the class in question in this email.

Now I think I have the sizers setup correctly, but I get all of the text
in the upper left and it all overlays.

You need to add:

                 self.SetAutoLayout(True)
                 self.SetSizer(sizer)

to the end of the torrentFrame.__init__() method. This tells wxPython to use the sizer you created to lay out the window's contents (the first instruction may even be optional nowadays -- I've been using wxPython for a while now, and it was needed when I started, but maybe SetSizer() now tells wxPython to automatically switch the window to automatically lay out its contents -- try it and see).

Hope this helps...

  - Erik.

That worked thanks for the quick help

Mike

···

Hi Mike,

I am trying to make my first wxpython application and I've run into a
problem trying to get the sizers to work.

Right now I just have 3 files. They are all located at

www.zcentric.com/~mike/wx

You can view those to get an overview of the app if needed. I will just
post the class in question in this email.

Now I think I have the sizers setup correctly, but I get all of the
text in the upper left and it all overlays.

You need to add:

                 self.SetAutoLayout(True)
                 self.SetSizer(sizer)

to the end of the torrentFrame.__init__() method. This tells wxPython
to use the sizer you created to lay out the window's contents (the
first instruction may even be optional nowadays -- I've been using
wxPython for a while now, and it was needed when I started, but maybe
SetSizer() now tells wxPython to automatically switch the window to
automatically lay out its contents -- try it and see).

Hope this helps...

  - Erik.

--------------------------------------------------------------------- To
unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org For
additional commands, e-mail: wxPython-users-help@lists.wxwindows.org