I’m forwarding this to the list again as it seemed to bounce. Sorry
if you get it twice
Brendan Simon.
Brendan Simon wrote:
···
I’m using wxPython and can’t get contraints to work
with any window/control within a wxNotebook page.It should be possible to have a wxNotebook page that contains other
windows/controls that are constrained in various ways, shouldn’t it ???
I have attatched a simple test program (bjs.py). Maybe I’m doing
something wrong.The class MyFrame contains two lines to instantiate MyWindow and MyNotebook
classes. Uncomment the one to test to see the differences.
Thanks for any help,
Brendan Simon.
--- #!/usr/bin/env python #----------------------------------------------------------------------------- # # FILENAME : bjs.py # # DESCRIPTION : A python program to test wxConstraints. # # NOTES : There are two classes used for testing. # They are called MyWindow and MyNotebook. # The class MyFrame instantiates these classes. # Test them individually by uncommenting the desired object # instance call in MyFrame. # # MyWindow should display 3 windows with position defined # by the wxConstraint values. This appears to work fine. # # MyNotebook should display a notebook with 2 windows # within it. I couldn't get the first window to resize # to anything other than the height/width of the notebook # page, so I decided to added another window with the page # window, hoping that I could size that one via constraints. # I STILL CAN'T GET IT TO WORK. ARGGGGHHH!!!! # #----------------------------------------------------------------------------- ## import all of the wxPython GUI package. from wxPython.wx import * #----------------------------------------------------------------------------- class MyWindow(wxWindow): def __init__(self, parent, id): wxWindow.__init__(self, parent, id) self.SetAutoLayout(true) self.SetBackgroundColour(wxGREEN) constraints = wxLayoutConstraints() constraints.top.Absolute(50) constraints.left.Absolute(50) constraints.width.Absolute(500) constraints.height.Absolute(500) self.SetConstraints(constraints) win1 = wxWindow(self, -1) win1.SetAutoLayout(true) win1.SetBackgroundColour(wxBLUE) constraints = wxLayoutConstraints() constraints.top.Absolute(50) constraints.left.Absolute(50) constraints.width.Absolute(200) constraints.height.Absolute(200) win1.SetConstraints(constraints) win2 = wxWindow(win1, -1) win2.SetAutoLayout(true) win2.SetBackgroundColour(wxCYAN) constraints = wxLayoutConstraints() constraints.top.Absolute(50) constraints.left.Absolute(50) constraints.width.Absolute(50) constraints.height.Absolute(50) win2.SetConstraints(constraints) #----------------------------------------------------------------------------- class MyNotebook(wxNotebook): def __init__(self, parent, id): wxNotebook.__init__(self, parent, id) self.SetAutoLayout(true) self.SetBackgroundColour(wxGREEN) constraints = wxLayoutConstraints() constraints.top.Absolute(50) constraints.left.Absolute(50) constraints.width.Absolute(500) constraints.height.Absolute(500) self.SetConstraints(constraints) win1 = wxWindow(self, -1) win1.SetAutoLayout(true) win1.SetBackgroundColour(wxBLUE) self.AddPage(win1, "A window") constraints = wxLayoutConstraints() constraints.top.Absolute(50) constraints.left.Absolute(50) constraints.width.Absolute(200) constraints.height.Absolute(200) win1.SetConstraints(constraints) win2 = wxWindow(win1, -1) win2.SetAutoLayout(true) win2.SetBackgroundColour(wxCYAN) constraints = wxLayoutConstraints() constraints.top.Absolute(50) constraints.left.Absolute(50) constraints.width.Absolute(50) constraints.height.Absolute(50) win2.SetConstraints(constraints) #----------------------------------------------------------------------------- ## Create a new frame class, derived from the wxPython Frame. class MyFrame(wxFrame): def __init__(self, parent, id, title): # First, call the base class' __init__ method to create the frame. wxFrame.__init__(self, parent, id, title, wxPoint(10, 10), wxSize(600, 600)) self.SetAutoLayout(true) #----------------------------------------------------- # Comment all lines except the *one* you want to test. #----------------------------------------------------- myNotebook = MyNotebook(self, -1) # myWindow = MyWindow(self, -1) #----------------------------------------------------------------------------- # Every wxWindows application must have a class derived from wxApp. class MyApp(wxApp): # wxWindows calls this method to initialize the application. def OnInit(self): # Create an instance of our customized Frame class. frame = MyFrame(NULL, -1, "CTAM CypherManager") frame.Show(true) # Tell wxWindows that this is our main window. self.SetTopWindow(frame) # Return a success flag. return true app = MyApp(0) # Create an instance of the application class. app.MainLoop() # Tell it to start processing events. #----------------------------------------------------------------------------- # EOF : $Source: d:/cvsroot/wxCypherManager/wxCypherManager.py,v $ #-----------------------------------------------------------------------------