Hi,
I am programming a wxFrame to open a window with a wxNoteBook inside.
The wxNotebook is composed of a thumb index and two pages ,"Page 1" and
"Page 2". In Page 1, there is a wxCtrlText ,which contains the word
'hello' and in Page 2, there is a wxButton "OK".
I am using wxLayoutConstraints to assign to the wxCtrlText, the width of
40 percent and the height of 20 percent of the main frame, and to centre
the button "OK" in the main frame.
The problem is :
when I modify the window's size with the size grip, the size und the
position of the elements stay the same. What can I do to force them to
change their size in the same way?
thanks for your help,
Graziella
···
--------------------------------------------------------------------------------
from wxPython.wx import *
wxID_TESTFRAME = NewId()
ID_Name = NewId()
ID_BUTTON = NewId()
class MyFrame(wxFrame):
def __init__(self, parent):
self._init_ctrls(parent)
self._initConstraints()
def _init_ctrls(self, parent):
wxFrame.__init__(self, parent, wxID_TESTFRAME, 'test',
size = wxSize(500, 300))
self.CreateStatusBar()
self.nb = wxNotebook(self, -1)
self.SetAutoLayout(true)
global win1
win1 = wxWindow(self.nb, -1)
self.text_Name = wxTextCtrl(win1, ID_Name, "Hello", wxPoint(120,
55), wxSize(110, 20))
self.nb.AddPage(win1, "Page 1")
global win2
win2 = wxWindow(self.nb, -1)
self.buttonOK = wxButton(win2, ID_BUTTON, "OK")
self.nb.AddPage(win2, "Page 2")
def _initConstraints(self):
c = wxLayoutConstraints()
c.left.SameAs(win1, wxLeft,40)
c.centreY.SameAs(win1, wxCentreY)
c.width.PercentOf(win1, wxWidth,40)
c.height.PercentOf(win1, wxHeight,20)
self.text_Name.SetConstraints(c)
#------------------------------------
c = wxLayoutConstraints()
c.left.AsIs()
c.bottom.AsIs()
c.right.AsIs()
c.height.AsIs()
self.nb.SetConstraints(c)
#------------------------------------
c = wxLayoutConstraints()
c.left.AsIs()
c.bottom.AsIs()
c.right.AsIs()
c.height.AsIs()
win1.SetConstraints(c)
#------------------------------------
c = wxLayoutConstraints()
c.centreX.SameAs(win2, wxCentreX)
c.centreY.SameAs(win2, wxCentreY)
c.width.AsIs()
c.height.AsIs()
self.buttonOK.SetConstraints(c)
#-----------------------------------
c = wxLayoutConstraints()
c.left.AsIs()
c.bottom.AsIs()
c.right.AsIs()
c.height.AsIs()
win2.SetConstraints(c)
self.Layout()
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(None)
frame.Show(true)
self.SetTopWindow(frame)
return(true)
app = MyApp(0)
app.MainLoop()
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users