[wxPython-users] sizing

Robin Dunn robin at alldunn.com
Thu Nov 2 20:45:15 PST 2006


Jack Andrews wrote:
> hi,
> 
> can you please help my poor list view expand to fit remaining space in
> window rather than being small and puny?

The main problem is that you are not telling the panel to be as large as 
the wizard page window, only to be as large as needed to hold the 
minimum sizes of the static text and the list control.  If you put the 
panel in a sizer and assign that to self, then you'll get closer to what 
you want.  The final step is to tell the panel's sizer to give all the 
extra vertical space to the listctrl by giving it a proportion > 0.

On the other hand, since you are not using the panel as the parent of 
the static text nor the list ctrl, you can just get rid of it and make 
the existing sizer belong to self, and it will then work even better.


import wx
import wx.wizard

choices = ['ODBC','Access','Excel','Text','Oracle','MySQL' ]
class ListAndStatic(wx.wizard.PyWizardPage):
     def __init__ ( self, parent ):
         wx.wizard.PyWizardPage.__init__(self,parent)
         self.previous=self.next=None
         self.list=wx.ListView(self,-1,
                     style=wx.LC_LIST|wx.LC_HRULES|wx.LC_VRULES)
         for c in choices:
             li=wx.ListItem()
             li.SetText(c)
             self.list.InsertItem(li)
         self.tx=wx.StaticText(self,-1,'From')
         self.sizer = wx.BoxSizer ( wx.VERTICAL )
         self.sizer.Add(self.tx,0,wx.EXPAND,0)
         self.sizer.Add(self.list,1,wx.EXPAND,0)
         self.SetSizer ( self.sizer )

     def GetNext(self):return None
     def GetPrev(self):return self.previous

app=wx.PySimpleApp()
wizard = wx.wizard.Wizard ( None, -1, 'DBK' )
p=ListAndStatic(wizard)
wizard.RunWizard(p)
wizard.Destroy()


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





More information about the wxpython-users mailing list