wxBoxSizers in window and two embedded panels.

Igor Prischepoff igor at tyumbit.ru
Mon Apr 21 09:02:14 EDT 2003


Hi!
 Sorry for my english, i'm not native english speaking man.
 Recently switched to python and it's wonderful wxPython toolkit.
 Having trouble with wxBoxSizer.
 I want this heirarchy

      wxWindow (a must! i've don't need to attach panels to wxFrame directly.)
       /    \
    Panel2  Panel1
    
Panel1 and panel2 must occupy all available screen space on window1.
Trouble is: they don't.
    

 ------------------------------  -----
 !  panel2                     !      !
 !-----------------------------!      !
 !  panel1                     !      !
 !                             !      !
 ------------------------------!      !
 !                 window1            !
 !------------------------------------
                                      
# Here is Boa generated app.(slightly changed.)
from wxPython.wx import *

def create(parent):
    return wxFrame1(parent)

[wxID_WXFRAME1, wxID_WXFRAME1PANEL1, wxID_WXFRAME1PANEL2, 
 wxID_WXFRAME1WINDOW1, 
] = map(lambda _init_ctrls: wxNewId(), range(4))

class wxFrame1(wxFrame):

    def __init__(self, parent):
        # generated method, don't edit
        wxFrame.__init__(self, id=wxID_WXFRAME1, name='', parent=parent,
              pos=wxPoint(252, 204), size=wxSize(768, 558),
              style=wxDEFAULT_FRAME_STYLE, title='wxFrame1')
        self.window1 = wxWindow(id=wxID_WXFRAME1WINDOW1, name='window1',
              parent=self, pos=wxPoint(0, 0), size=wxSize(760, 531), style=wxEXPAND)

        self.panel1 = wxPanel(id=wxID_WXFRAME1PANEL1, name='panel1',
              parent=self.window1, pos=wxPoint(16, 8), size=wxSize(536, 32),
              style=wxEXPAND)

        self.panel2 = wxPanel(id=wxID_WXFRAME1PANEL2, name='panel2',
              parent=self.window1, pos=wxPoint(24, 56), size=wxSize(528, 376),
              style=0)
# Just to see where which colour.
        self.window1.SetBackgroundColour("BLACK")
        self.panel2.SetBackgroundColour("BLUE")
        self.panel1.SetBackgroundColour("RED")
#       
# Am i miss something about Sizers?
# 
        box=wxBoxSizer(wxVERTICAL)
# put into sizer panel2 and panel1 with proportion factor 1:50
        box.Add(self.panel2,1,wxEXPAND)
        box.Add(self.panel1,50,wxEXPAND)
# Attach sizer to window1
        self.window1.SetSizer(box)
        self.window1.SetAutoLayout(true)
        self.window1.Layout()

class BoaApp(wxApp):
    def OnInit(self):
        wxInitAllImageHandlers()
        self.main = create(None)
        self.SetTopWindow(self.main)
        self.main.Show();
        return True


if __name__ == '__main__':
    application = BoaApp(0)
    application.MainLoop()
# end of code
# 
When running this app i've got initial sizes of panel1 and panel2
ok, but when resizing main window with mouse,my panels not resize.
In short - there must not be BLACK colour in my window.

I've installed sizer and attached it to window1.
Put there 2 panels, panel1 and panel2.
How to force my panels to rezise properly, i.e. to occupy all available
space in window1?
Sorry if it's wrong list, i've know there is wxPython list but can not
subscribe to it. There are trouble with their subscriber software.

Thanks in advance.

P.S. win2k + python 2.2.2. + wxPython - last stable release.

                     mailto:igor at tyumbit.ru






More information about the Python-list mailing list