13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Layout management in <strong>wxPython</strong>http://www.zetcode.com/wxpython/layout/Figure: FlexGridSizer examplewx.GridBagSizer<strong>The</strong> most complicated sizer in <strong>wxPython</strong>. Many programmer find it difficult to use.This kind of sizer is not typical only for <strong>wxPython</strong>. We can find it in other toolkits aswell. <strong>The</strong>re is no magic in using this sizer. Even though it is more complicated, it iscertainly not rocket science. All we have to do is to create several layouts with it. Findall the quirks. Play with it a bit. <strong>The</strong>re are more difficult things in programming.Believe me.This sizer enables explicit positioning of items. Items can also optionally span morethan one row and/or column. wx.GridBagSizer has a simple constructor.wx.GridBagSizer(integer vgap, integer hgap)<strong>The</strong> vertical and the horizontal gap defines the space in pixels used among allchildren. We add items to the grid with the Add() method.Add(self, item, tuple pos, tuple span=wx.DefaultSpan, integer flag=0, integer border=0, userData=None)Item is a widget that you insert into the grid. pos specifies the position in the virtualgrid. <strong>The</strong> topleft cell has pos of (0, 0). span is an optional spanning of the widget.e.g. span of (3, 2) spans a widget across 3 rows and 2 columns. flag and border werediscussed earlier by wx.BoxSizer. <strong>The</strong> items in the grid can change their size or keepthe default size, when the window is resized. If you want your items to grow andshrink, you can use these two methods.AddGrowableRow(integer row)AddGrowableCol(integer col)Rename dialog12 de 17 27/04/2008 1:03

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!