13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>The</strong> Graphics Device Interfacehttp://www.zetcode.com/wxpython/gdi/wxBufferedDCwxBufferedPaintDCwxPostScriptDCwxMemoryDCwxPrinterDCwxScreenDCwxClientDCwxPaintDCwxWindowDC<strong>The</strong> wx.ScreenDC is used to draw anywhere on the screen.<strong>The</strong> wx.WindowDC is used if we want to paint on the wholewindow (Windows only). This includes window decorations.<strong>The</strong> wx.ClientDC is used to draw on the client area of awindow. <strong>The</strong> client area is the area of a window without it'sdecorations (title and border). <strong>The</strong> wx.PaintDC is used to drawon the client area as well. But there is one difference betweenthe wx.PaintDC and the wx.ClientDC. <strong>The</strong> wx.PaintDC shouldbe used only from a wx.PaintEvent. <strong>The</strong> wx.ClientDC shoudnot be used from a wx.PaintEvent. <strong>The</strong> wx.MemoryDC is usedto draw graphics on the bitmap. <strong>The</strong> wx.PostScriptDC is usedto write to PostScript files on any platform. <strong>The</strong> wx.PrinterDCis used to access a printer (Windows only).Drawing a simple lineOur first example will draw a simple line onto the client area ofa window.DrawLine(int x1, int y1, int x2, int y2)This method draws a line from the first point to the second.Excluding the second point.#!/usr/bin/python# line1.pyimport wxclass Line(wx.Frame):def __init__(self, parent, id, title):2 de 44 27/04/2008 1:08

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

Saved successfully!

Ooh no, something went wrong!