I'm fairly new to wxPython and am having some issues Trying to layout the page
how I want.
What I'm after is a Notebook taking up most of the window with 5px borders, with
a band at the bottom with OK, Cancel, Apply right aligned all with px borders.
I've posted what I have so far, it seems almost right although I've had to
manually set exactly the right positions and sizes in quite a few places which
I'm sure there's a better way of doing (on the page __init__s, notebook
constructor). Also all the border areas are all dark grey because you can see
behind to the frame, how can I get the panel to show here in the nice light
grey? Also the second panel with the second sizer in is up in the top left
corner and I'm not sure why!
Also I just noticed the notebook goes off the edge of the viewable area on the
right, probably due to the size I gave it is too wide.
There's also not a 5px gap between the buttons either
Any help would be greatly appreciated, I've tried so many different thing now-
I'm hoping this will be easy for someone with more experience!
import wx
class TestPage(wx.Panel):
def __init__(self,parent):
wx.Panel.__init__(self,parent,size=(-1,300))
t= wx.StaticText(self,-1,"Blahhh")
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="Settings", style=wx.DEFAULT_FRAME_STYLE
^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX ^ wx.MINIMIZE_BOX, size=wx.Size(550,370))
p1= wx.Panel(self)
p2= wx.Panel(self)
nb= wx.Notebook(p1,pos=(5,5),size=(539,295))
#p= wx.Panel(self,size=wx.Size(550,370))
## sizer= wx.BoxSizer(wx.HORIZONTAL)
## sizer.Add(p)
## self.SetSizer(sizer)
···
##
# create the page windows as children of the notebook
page1= TestPage(nb)
page2= TestPage(nb)
page3= TestPage(nb)
page4= TestPage(nb)
page5= TestPage(nb)
# add the pages to the notebook with the label to show on the tab
nb.AddPage(page1, "Page 1")
nb.AddPage(page2, "Page 2")
nb.AddPage(page3, "Page 3")
nb.AddPage(page4, "Page 4")
nb.AddPage(page5, "Page 5")
self.sizer2= wx.BoxSizer(wx.HORIZONTAL)
self.ok_btn= wx.Button(self,wx.ID_OK)
self.cancel_btn= wx.Button(self,wx.ID_CANCEL)
self.sizer2.Add(self.ok_btn,0,wx.EXPAND)
self.sizer2.Add(self.cancel_btn,1,wx.EXPAND)
self.sizer= wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(p1,1,wx.ALL^wx.BOTTOM|wx.EXPAND,5)
#self.sizer.Add(self.panel,0)
self.sizer.Add(self.sizer2,0,wx.ALL|wx.ALIGN_RIGHT,5)
self.SetSizer(self.sizer)
if __name__ == "__main__":
app = wx.App(False)
MainFrame().Show()
app.MainLoop()