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/space to one widget, it is applied to the whole row. That's why I did not specifybottom space for the ok button. A careful reader might notice, that we did not specifyany space between the two buttons. e.g. we did not put any space to the right of theok button, or to the right of the close button. In the constructor of thewx.GridBagSizer, we put some space between all widgets. So there is some spacealready.sizer.AddGrowableCol(1)sizer.AddGrowableRow(2)<strong>The</strong> last thing we must do, is to make our dialog resizable. We make the secondcolumn and the third row growable. Now we can expand or shrink our window. Try tocomment those two lines and see what happens.Open Resource<strong>The</strong> next example will be a bit more complicated. We will create an Open Resourcewindow. This example will show a layout of a very handy dialog which you can find inEclipse IDE.Figure: Open Resource window#!/usr/bin/python# openresource.pyimport wxclass OpenResource(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(400, 500))panel = wx.Panel(self, -1)sizer = wx.GridBagSizer(4, 4)text1 = wx.StaticText(panel, -1, 'Select a resource to open')14 de 17 27/04/2008 1:03

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

Saved successfully!

Ooh no, something went wrong!