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/2. <strong>The</strong>y are added into a horizontal wx.BoxSizer. Button with proportion 0 will notchange at all. Button with proportion 2 will change twice more than the one withproportion 1 in the horizontal dimension.With the flag parameter you can further configure the behaviour of the widgets withina wx.BoxSizer. We can control the border between the widgets. We add some spacebetween widgets in pixels. In order to apply border we need to define sides, wherethe border will be used. We can combine them with the | operator. e.g wx.LEFT |wx.BOTTOM. We can choose between these flags:wx.LEFTwx.RIGHTwx.BOTTOMwx.TOPwx.ALLFigure: border around a panel#!/usr/bin/python# border.pyimport wxclass Border(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(250, 200))panel = wx.Panel(self, -1)panel.SetBackgroundColour('#4f5049')vbox = wx.BoxSizer(wx.VERTICAL)midPan = wx.Panel(panel, -1)midPan.SetBackgroundColour('#ededed')vbox.Add(midPan, 1, wx.EXPAND | wx.ALL, 20)panel.SetSizer(vbox)self.Centre()self.Show(True)app = wx.App()Border(None, -1, '')app.MainLoop()vbox.Add(midPan, 1, wx.EXPAND | wx.ALL, 20)In border.py we have placed a 20 px border around a midPan panel. wx.ALL appliesthe border size to all four sides.If we use wx.EXPAND flag, our widget will use all the space that has been allotted toit. Lastly, we can also define the alignment of our widgets. We do it with the followingflags :4 de 17 27/04/2008 1:03

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

Saved successfully!

Ooh no, something went wrong!