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/<strong>The</strong> options are:wx.CAP_ROUNDwx.CAP_PROJECTINGwx.CAP_BUTT<strong>The</strong> wx.CAP_ROUND will draw rounded ends. <strong>The</strong>wx.CAP_PROJECTING and the wx.CAP_BUTT will both drawsquare ends. <strong>The</strong> difference between them is that thewx.CAP_PROJECTING will extend beyond the end point by thehalf of the line size. <strong>The</strong> wx.CAP_ROUND will extend beyondthe end point as well.#!/usr/bin/python# joinscaps.pyimport wxclass JoinsCaps(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(330, 300))self.Bind(wx.EVT_PAINT, self.OnPaint)self.Centre()self.Show(True)def OnPaint(self, event):dc = wx.PaintDC(self)pen = wx.Pen('#4c4c4c', 10, wx.SOLID)pen.SetJoin(wx.JOIN_MITER)dc.SetPen(pen)dc.DrawRectangle(15, 15, 80, 50)pen.SetJoin(wx.JOIN_BEVEL)dc.SetPen(pen)dc.DrawRectangle(125, 15, 80, 50)pen.SetJoin(wx.JOIN_ROUND)dc.SetPen(pen)dc.DrawRectangle(235, 15, 80, 50)pen.SetCap(wx.CAP_BUTT)dc.SetPen(pen)dc.DrawLine(30, 150, 150, 150)pen.SetCap(wx.CAP_PROJECTING)dc.SetPen(pen)dc.DrawLine(30, 190, 150, 190)11 de 44 27/04/2008 1:08

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

Saved successfully!

Ooh no, something went wrong!