FAQ
Hi,

I'm trying to understand one of the wiki wxPython tutorial, and I must
admit I`m a bit baffled by sizers. If I run the following relevant
piece of code, I get the result I expect, i.e a 800x600 window being
opened (sorry for the formatting):

objFrame = MainWindow(None, -1, "Small Editor", (800, 600))

def __init__(self, parent, id, title, custom_size):
wx.Frame.__init__(self, parent, wx.ID_ANY, title, size =
custom_size,
style = wx.DEFAULT_FRAME_STYLE |
wx.NO_FULL_REPAINT_ON_RESIZE)

However, if I add this part from the tutorial, I get a much smaller
window. Why is there an interference with the result I want when
adding the sizer code?

Here's the code:

# Sizer section to understand
self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
self.buttons = []

for nI in range(0, 6):
self.buttons.append(wx.Button(self, ID_BUTTON + nI, "Button &" +
`nI`))
self.sizer2.Add(self.buttons[nI], 1, wx.EXPAND)

self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.control, 1, wx.EXPAND)
self.sizer.Add(self.sizer2, 0, wx.EXPAND)

self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)
# End of sizer section

Thanks

Denis

Search Discussions

  • Brian Victor at Feb 22, 2005 at 4:59 pm

    Deltones wrote:
    However, if I add this part from the tutorial, I get a much smaller
    window. Why is there an interference with the result I want when
    adding the sizer code? [snip]
    self.sizer.Fit(self)
    As noted in the the docs for Fit(): "Tell the sizer to resize the window
    to match the sizer's minimal size." Take this call out and the size
    should be as you expect.

    --
    Brian
  • Deltones at Feb 23, 2005 at 2:19 pm
    Brian Victor <bhv1 at psu.edu> wrote in message news:<slrnd1mp6p.t0p.bhv1 at pa-steclge-u3-c3b-133.stcgpa.adelphia.net>...
    Deltones wrote:
    However, if I add this part from the tutorial, I get a much smaller
    window. Why is there an interference with the result I want when
    adding the sizer code? [snip]
    self.sizer.Fit(self)
    As noted in the the docs for Fit(): "Tell the sizer to resize the window
    to match the sizer's minimal size." Take this call out and the size
    should be as you expect.
    Thanks Brian, that was it. I admit I'm having quite a lot of fun
    learning the Python/wxPython combo, but man is there a lot of concepts
    to grasp!

    Denis

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 22, '05 at 4:37p
activeFeb 23, '05 at 2:19p
posts3
users2
websitepython.org

2 users in discussion

Deltones: 2 posts Brian Victor: 1 post

People

Translate

site design / logo © 2022 Grokbase