[wxPython] More N00b notebook woes

Okay, attached here is some code that doesn't work. Could someone please tell me why?
I expect it to pop a window with a text field and buttons in.

David Gentle

noteshow.py (2.54 KB)

David Gentle wrote:

Okay, attached here is some code that doesn't work. Could someone please tell me why?
I expect it to pop a window with a text field and buttons in.

You were trying to do too much. If a frame has only one child it will automatically size/position it to fill the client area. Notebooks do the same with their page windows. Here's your code with a bunch of stuff removed, and a couple little changes:

from wxPython.wx import *

class MyFrame(wxFrame):
     def __init__(self, parent, ID, title):
         wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(200, 250))

         self.wholething = wxPanel(self, 34, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER)
         self.wholething.SetAutoLayout(true)
         self.wholething.SetBackgroundColour("BLUE")

         self.notebook=wxNotebook(self.wholething,12)

         self.entry = wxPanel(self.notebook, 35, wxDefaultPosition,
                              wxDefaultSize, wxSIMPLE_BORDER)
         self.entry.SetBackgroundColour("RED")
         self.notebook.AddPage(self.entry, "buggy")
         self.entry.SetAutoLayout(true)

         dogsy=wxLayoutConstraints()
         dogsy.top.SameAs(self.wholething,wxTop,10)
         dogsy.left.SameAs(self.wholething,wxLeft)
         dogsy.right.SameAs(self.wholething,wxRight)
         dogsy.bottom.SameAs(self.wholething,wxBottom,10)
         self.notebook.SetConstraints(dogsy)

         self.t1 = wxTextCtrl(self.entry, 300,
                              "This isn't printing, help",
                              size=(125, 200), style=wxTE_MULTILINE)
         dogsy=wxLayoutConstraints()
         dogsy.top.SameAs(self.entry,wxTop)
         dogsy.left.SameAs(self.entry,wxLeft)
         dogsy.right.SameAs(self.entry,wxRight)
         dogsy.height.Absolute(150)
         self.t1.SetConstraints(dogsy)

         b1 = wxButton(self.entry, 100, "more")
         b2 = wxButton(self.entry, 200, "mousey")

         dogsy=wxLayoutConstraints()
         dogsy.top.Below(self.t1)
         dogsy.left.SameAs(self.entry, wxLeft)
         dogsy.right.SameAs(self.entry, wxCentreX)
         dogsy.height.Absolute(20)
         b1.SetConstraints(dogsy)

         constraint=wxLayoutConstraints()
         constraint.top.Below(self.t1)
         constraint.left.RightOf(b1)
         constraint.right.SameAs(self.entry,wxRight)
         constraint.height.Absolute(20)
         b2.SetConstraints(constraint)

     def EvtText(self, event):
         print event.GetString()

     def But(self, event):
         print self.t1.GetValue()

     def TimeToQuit(self, event):
         self.Close(true)

class MyApp(wxApp):
     def OnInit(self):
         frame = MyFrame(NULL, -1, "tester")
         frame.Show(true)
         self.SetTopWindow(frame)
         return true

app = MyApp(0)
app.MainLoop()

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!