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.

http://www.zetcode.com/wxpython/firststeps/already saw a pos parameter in the constructor of ourwx.Frame widget. By providing other than the defaultvalues, we can control the position ourselves.MethodMove(wx.Point point)MoveXY(int x, int y)SetPosition(wx.Point point)SetDimensions(wx.Point point,wx.Size size)Descriptionmove a window tothe given positionmove a window tothe given positionset the position of awindowset the position andthe size of a window<strong>The</strong>re are several methods to do this. Toss a coin.#!/usr/bin/python# move.pyimport wxclass Move(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title)self.Move((800, 250))self.Show(True)app = wx.App()Move(None, -1, 'Move')app.MainLoop()<strong>The</strong>re is one particular situation. We might want to displayour window maximized. In this case, the window ispositioned at (0, 0) and takes the whole screen. <strong>wxPython</strong>internally calculates the screen coordinates. To maximizeour wx.Frame, we call the Maximize() method. If we want tocenter our application on the screen, <strong>wxPython</strong> has a handymethod. <strong>The</strong> Centre() method simply centers the window onthe screen. No need to calculate the width and the height ofthe screen. Simply call the method.5 de 8 27/04/2008 1:01

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

Saved successfully!

Ooh no, something went wrong!