-
June 17th, 2011, 03:00 PM
#1
Trouble with sizers
Hey everyone,
So I seem to be having some trouble with my box sizers and I don't really know how to fix it. I'm only just getting started with wxPython and I can't fix this on my own. If you run the code you'll notice that they are all in line, but I would like the top row to be varying, and the bottom one to be in line.
Any help you guys could offer would be greatly appreciated.
P.S. Please excuse the way the code is written, I'm new to code gurus and I don't know how to format it.
import wx
class MainPanel(wx.Panel):
---def __init__(self,parent):
------wx.Panel.__init__(self,parent)
------# the sizers
------mainSizer=wx.BoxSizer(wx.VERTICAL)
------topBox = wx.BoxSizer(wx.HORIZONTAL)
------bigBox = wx.BoxSizer(wx.VERTICAL)
------bxdInBox=wx.BoxSizer(wx.HORIZONTAL)
------bottomBox=wx.BoxSizer(wx.HORIZONTAL)
------# the buttons
------self.topBtn = wx.Button(self, label="Top")
------self.centerBtn=wx.Button(self,label="Center")
------self.bottomBtn=wx.Button(self,label="Bottom")
------self.growBtn=wx.Button(self,label="Grow")
------self.propGrowthBtn=wx.Button(self,label="Proportionate Growth")
------self.bxdLeftBtn=wx.Button(self,label="Left")
------self.bxdCenterBtn=wx.Button(self,label="Center")
------self.bxdRightBtn=wx.Button(self,label="Right")
------self.lowLeftBtn=wx.Button(self,label="Left")
------self.lowCenterBtn=wx.Button(self,label="Center")
------self.lowRightBtn=wx.Button(self,label="Right")
------# add the buttons to the sizers
------topBox.Add(self.topBtn,0, wx.ALIGN_TOP)
------topBox.Add(self.centerBtn,0,wx.ALIGN_CENTER)
------topBox.Add(self.bottomBtn,0,wx.ALIGN_BOTTOM)
------topBox.Add(self.growBtn,0,wx.EXPAND)
------bxdInBox.Add(self.bxdLeftBtn)
------bxdInBox.Add(self.bxdCenterBtn)
------bxdInBox.Add(self.bxdRightBtn)
------# add sizers to mainSizer
------mainSizer.Add(topBox)
------mainSizer.Add(bxdInBox)
------self.SetSizerAndFit(mainSizer)
app = wx.App(False)
frame1 = wx.Frame(None, title ="Demo")
nb = wx.Notebook(frame1)
nb.AddPage(MainPanel(nb),"Box Sizers")
frame1.SetSizeHints(200,100,500,400)
frame1.Show()
app.MainLoop()
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|