Oops, hit the send button by mistake :-S
app.runOK shows a blue and a red panel on 800x600 Frame
app.runNotOK shows a blue 800x600 Frame
app.runNotOK actually shows a blue panel which is filled to the size of the frame. By default, if you have just one panel in a frame, the panel automatically fills the frame. Really, you need to use sizers (took me ages to get the hang of them) to fit the two panels into the frame.
Here's a sample:
from wxPython.wx import *
class myApp(wxApp):
def OnInit(self):
topFrame = myTopFrame(NULL, "Test App")
self.SetTopWindow(topFrame) # set topFrame
# to be top-level window
topFrame.Show(true) # show the frame
return true
class myTopFrame(wxFrame):
def __init__(self, parent, caption):
wxFrame.__init__(self, parent, -1, caption)
panel1 = wxPanel(self, -1)
panel1.SetBackgroundColour(wxRED)
panel2 = wxPanel(self, -2)
panel2.SetBackgroundColour(wxBLUE)
sizer = wxBoxSizer(wxVERTICAL) # use wxVERTICAL or wxHORIZONTAL
# to change the orientation of
# the sizer
sizer.Add(panel1, 1, wxEXPAND)
sizer.Add(panel2, 1, wxEXPAND)
self.SetAutoLayout(TRUE)
self.SetSizer(sizer)
sizer.Fit(self)
self.SetSize(wxSize(800,600))
if __name__ == "__main__":
app = myApp()
app.MainLoop()
If you need to layout the panels manually and really do want a panel that doesn't fill the frame.
If you need to know more about sizers, check out the excellent PyWiki pages http://wiki.wxpython.org/index.cgi/UsingSizers
Hope that helps,
James Shaw
···
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.