[wxPython-users] Grid Resize overrides layout?

Mike Driscoll mdriscoll at co.marshall.ia.us
Wed Sep 5 10:21:56 PDT 2007


Robin,

> -----Original Message-----
> From: Robin Dunn [mailto:robin at alldunn.com] 
> Sent: Tuesday, September 04, 2007 5:35 PM
> To: wxPython-users at lists.wxwidgets.org
> Subject: Re: [wxPython-users] Grid Resize overrides layout?
> 
> Mike Driscoll wrote:
> 
> > I would still like to know why the Layout() command doesn't 
> work though.
> > I've created a sample script that illustrates the problem. When you 
> > click the button, it changes the font size in cell (0,0) to 
> 12 point 
> > Swiss, bold and then calls the AutoSize function and then 
> the Layout 
> > function. This will then cause the grid to change shape 
> slightly and 
> > "push" the button off the edge of the panel. If you resize 
> the panel 
> > with your mouse, the button reappears.
> 
> You are telling the panel to redo it's layout, but it is 
> still constrained to the size of the frame.  If you want the 
> frame to resize to meet the new layout needs of the panel, 
> you need to do it yourself.
> 
> 
>      def onFontChange(self, event):
>          font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)
>          self.sheet.SetCellFont(0,0,font)
>          self.sheet.AutoSize()
>          #self.panel.Layout()
>          self.SetClientSize(self.panel.GetBestSize())
> 
> Notice that the Layout() is not needed anymore because it 
> will happen automatically when the resize happens.
> 
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org  Java give you jitters?  Relax with wxPython!
> 

That's a really cool trick. It works for me as expected. Hopefully I won't
have any other goofy issues. Thanks a lot!

Mike





More information about the wxpython-users mailing list