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/wx.PenPen is an elementary graphics object. It is used to draw lines,curves and outlines of rectangles, ellipses, polygons or othershapes.wx.Pen(wx.Colour colour, widht=1, style=wx.SOLID)<strong>The</strong> wx.Pen constructor has three parameters. Colour, widthand style. Follows a list of possible pen styles.Pen styleswx.SOLIDwx.DOTwx.LONG_DASHwx.SHORT_DASHwx.DOT_DASHwx.TRANSPARENT#!/usr/bin/python# pens.pyimport wxclass Pens(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(350, 190))self.Bind(wx.EVT_PAINT, self.OnPaint)self.Centre()self.Show(True)def OnPaint(self, event):dc = wx.PaintDC(self)dc.SetPen(wx.Pen('#4c4c4c', 1, wx.SOLID))dc.DrawRectangle(10, 15, 90, 60)dc.SetPen(wx.Pen('#4c4c4c', 1, wx.DOT))dc.DrawRectangle(130, 15, 90, 60)dc.SetPen(wx.Pen('#4c4c4c', 1, wx.LONG_DASH))dc.DrawRectangle(250, 15, 90, 60)dc.SetPen(wx.Pen('#4c4c4c', 1, wx.SHORT_DASH))9 de 44 27/04/2008 1:08

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

Saved successfully!

Ooh no, something went wrong!