This Notebook example runs, but doesn't yield the expected results. One
would expect to see the added Notebook pages as well as the other features
in the code.
Thanks in anticipation for any hints.
Ashu Akoachere
···
--------------------------------------------------------------
from wxPython.wx import *
#import ColorPanel
wxID_TESTFRAME = wxNewId()
ID_Name = wxNewId()
ID_BUTTON = wxNewId()
class MainWindow(wxFrame):
""" Define a new frame class"""
def __init__(self,parent):
self._init_ctrls(parent)
self._initConstraints()
def _init_ctrls(self, parent):
wxFrame.__init__(self, parent, wxID_TESTFRAME, 'NoteBook DEMO',
size = wxSize(500,300))
self.CreateStatusBar()
#win = self.makeColorPanel(wxBLUE)
#self.AddPage("Blue")
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 = MainWindow(None)
frame.Show(true)
self.SetTopWindow(frame)
return(true)
app = MyApp(0)
app.MainLoop()