[wxPython-users] Setting wx.Grid Widget Size

Christopher Barker Chris.Barker at noaa.gov
Thu Aug 30 13:02:20 PDT 2007


Rich,

It would help if you posted a bit more code. Ideally, make a small, 
stand-alone sample that puts your modData object and button and all in a 
Frame and shows it -- then we can see what you're doing and test it.

Rich Shepard wrote:
>   Using a grid with a separate data table. The class modData initiates the
> grid (widget, I presume) as:
> 
> class modData(wx.grid.Grid):
> 
>   appData = config.appData
> 
>   def __init__(self, parent, log):
>     wx.grid.Grid.__init__(self, parent, -1, size=wx.Size(800, 400))
>     self.tableBase = GenericTable(data, rowLabels, colLabels)
>     self.SetTable(self.tableBase)

>   Thanks to Chris, I add only 'self' to the vertical box sizer,

That gets you closer, but If I am guessing right about what you are 
doing (more code would help....). It sounds like you are putting self in 
a sizer, then setting the sizer on self -- that's not going to work. 
It's a hierarchy. I think you want something like this:

class modDataPanel(wx.Panel):
     def __init__(......)
         wx.Panel.__init__(....)

         self.modgrid = modData(self,.....)
         self.SaveButton = wx.Button(self, .....)
         self.SaveButton.Bind(wx.EVT_BUTTON,
         sizer = wx.Sizer(wx.VERTICAL)

         sizer.Add(self.modgrid, .....)
         sizer.Add(self.SaveButton, ....)

         self.SetSizer(sizer)


In short -- if you want to put both a Grid and a Button on something, 
you put them on Panel -- a Grid can't put a Button on itself. (at least 
not the way you want it)

-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list