Hello,
I'd be grateful for the help with a problem with a sizer. I want to
place the sizer on a panel which is smaller than the frame.
Unfortunately, all the widgets get positioned in the top left corner,
one over each other, instead of lining up in a grid. Obviously, I'm
doing something wrong but I can't figure out what. Thanks in advance!
Eli Nazarova
import wx
class View(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, -1, 'Test', size=(400, 400))
self.panel0 = wx.Panel(self, size=(400, 100), pos=(0,0))
self.panel0.SetBackgroundColour(wx.BLACK)
self.panel = wx.Panel(self, size=(400, 300), pos=(0, 100))
self.panel.SetBackgroundColour(wx.WHITE)
self.sizer = wx.GridSizer(cols = 2, hgap = 10, vgap=10)
labels = ['one', 'two', 'three', 'four']
for label in labels:
self.sizer.Add(wx.StaticText(self, -1, label), 0)
self.panel.SetSizer(self.sizer)
self.TopSizer.Fit(self.panel)
self.Show()
if __name__ == '__main__':
app = wx.PySimpleApp()
view = View(None, -1)
app.MainLoop()