[wxPython-users] "Liquid" windows
Werner F. Bruhin
werner.bruhin at free.fr
Sun Mar 4 01:23:18 PST 2007
Hi Lucas,
Lucas wrote:
> Hi,
> I'm a beginner at wxPython, and I have come up with a problem.
>
> #!/usr/bin/env python
> import wx
> items = ['Water', 'Food', 'Medicine']
> prices = ['50', '150', '600']
> class App(wx.Frame):
> def __init__(self,parent, id):
> wx.Frame.__init__(self, parent, id, "Trader")
> self.sizer = wx.GridBagSizer(0, 0)
> self.sizer.SetRows(1)
> self.sizer.SetCols(2)
> self.sizer.AddGrowableRow(0,1)
> self.sizer.AddGrowableCol(0,1)
> self.sizer.AddGrowableCol(1,1)
> self.itemlist = wx.ListBox(self, -1)
> self.itemlist.Set(items)
> self.pricelist = wx.ListBox(self, -1)
> self.pricelist.Set(prices)
> self.sizer.Add(self.itemlist,wx.GBPosition(1,1))
> self.sizer.Add(self.pricelist,wx.GBPosition(1,2))
> self.SetSizer(self.sizer)
> self.SetAutoLayout(True)
> self.sizer.Fit(self)
> self.Show(True)
> app = wx.PySimpleApp()
> main = App(None, -1)
> app.MainLoop()
>
> In this code, you can see that when you resize the window, the lists stay the
> same size, and it doesn't look very nice. Is there a way so that everythong can
> be 'liquid' and resize with the window?
>
You were close, you had a problem with the col/row numbers and you need
to add a flag.
Changed the following lines:
self.sizer.AddGrowableRow(0,1)
self.sizer.AddGrowableCol(0,1)
self.sizer.AddGrowableCol(1,1)
self.sizer.Add(self.itemlist,wx.GBPosition(0,0), flag=wx.EXPAND)
self.sizer.Add(self.pricelist,wx.GBPosition(0,1), flag=wx.EXPAND)
Werner
More information about the wxpython-users
mailing list