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.

<strong>The</strong> Graphics Device Interfacehttp://www.zetcode.com/wxpython/gdi/CrossHair(int x, int y)<strong>The</strong> method draws a cross hair centered on coordinates x, y.#!/usr/bin/python# crosshair.pyimport wxclass CrossHair(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(250, 150))self.Bind(wx.EVT_PAINT, self.OnPaint)self.Centre()self.Show(True)def OnPaint(self, event):dc = wx.PaintDC(self)dc.CrossHair(50, 50)app = wx.App()CrossHair(None, -1, 'CrossHair')app.MainLoop()Figure: A Cross HairIn the following code example we will create a functionalityoften seen in games. 'Aiming at the enemy.'#!/usr/bin/python# crosshair2.py20 de 44 27/04/2008 1:08

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

Saved successfully!

Ooh no, something went wrong!