****** wx.Pen ****** Inheritance diagram for `wx.Pen`: | .. inheritance-diagram:: wx.Pen | Description =========== A pen is a drawing tool for drawing outlines. It is used for drawing lines and painting the outline of rectangles, ellipses, etc. It has a colour, a width and a style. .. seealso:: `wx.PenList `_, `wx.DC `_, `wx.DC.SetPen `_ Predefined Pens ^^^^^^^^^^^^^^^ wxPython has a number of predefined pens (built-in), which are: * **wx.RED_PEN** * **wx.CYAN_PEN** * **wx.GREEN_PEN** * **wx.BLACK_PEN** * **wx.WHITE_PEN** * **wx.TRANSPARENT_PEN** * **wx.BLACK_DASHED_PEN** * **wx.GREY_PEN** * **wx.MEDIUM_GREY_PEN** * **wx.LIGHT_GREY_PEN** Derived From ^^^^^^^^^^^^^ * `wx.GDIObject `_ * `wx.Object `_ Remarks ^^^^^^^ On a monochrome display, wxWidgets shows all non-white pens as black. An application may wish to dynamically create pens with different string characteristics, and there is the consequent danger that a large number of duplicate pens will be created. Therefore an application may wish to get a pointer to a pen by using the global list of pens `wx.ThePenList`, and calling the member function `FindOrCreatePen`. See the entry for `wx.PenList `_. This class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. You can therefore use actual objects instead of pointers without efficiency problems. If an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected. Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `GetCap <#GetCap>`_ * `GetColour <#GetColour>`_ * `GetDashCount <#GetDashCount>`_ * `GetDashes <#GetDashes>`_ * `GetJoin <#GetJoin>`_ * `GetStipple <#GetStipple>`_ * `GetStyle <#GetStyle>`_ * `GetWidth <#GetWidth>`_ * `IsOk <#IsOk>`_ * `SetCap <#SetCap>`_ * `SetColour <#SetColour>`_ * `SetDashes <#SetDashes>`_ * `SetJoin <#SetJoin>`_ * `SetStipple <#SetStipple>`_ * `SetStyle <#SetStyle>`_ * `SetWidth <#SetWidth>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Cap <#Cap>`_ * `Colour <#Colour>`_ * `DashCount <#DashCount>`_ * `Dashes <#Dashes>`_ * `Join <#Join>`_ * `Stipple <#Stipple>`_ * `Style <#Style>`_ * `Width <#Width>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(colour, width=1, style=wx.SOLID) Constructs a pen from a colour object, pen width and style. **Parameters:** * `colour` (`wx.Colour `_): A colour object. * `width` (int): Pen width. Under Windows, the pen width cannot be greater than 1 if the style is ``wx.DOT``, ``wx.LONG_DASH``, ``wx.SHORT_DASH``, ``wx.DOT_DASH``, or ``wx.USER_DASH``. * `style` (int): The style may be one of the following: ============================== ======================================= Pen Styles Description ============================== ======================================= ``wx.SOLID`` Solid style. ``wx.TRANSPARENT`` No pen is used. ``wx.DOT`` Dotted style. ``wx.LONG_DASH`` Long dashed style. ``wx.SHORT_DASH`` Short dashed style. ``wx.DOT_DASH`` Dot and dash style. ``wx.STIPPLE`` Use the stipple bitmap. ``wx.USER_DASH`` Use the user dashes: see `SetDashes <#SetDashes>`_ ``wx.BDIAGONAL_HATCH`` Backward diagonal hatch. ``wx.CROSSDIAG_HATCH`` Cross-diagonal hatch. ``wx.FDIAGONAL_HATCH`` Forward diagonal hatch. ``wx.CROSS_HATCH`` Cross hatch. ``wx.HORIZONTAL_HATCH`` Horizontal hatch. ``wx.VERTICAL_HATCH`` Vertical hatch. ============================== ======================================= | **Returns:** `wx.Pen `_ -------- .. method:: GetCap() Returns the pen cap style, which may be one of ``wx.CAP_ROUND``, ``wx.CAP_PROJECTING`` and ``wx.CAP_BUTT``. The default is ``wx.CAP_ROUND``. | **Returns:** `int` .. seealso:: `SetCap <#SetCap>`_ -------- .. method:: GetColour() Returns a reference to the pen colour. | **Returns:** `wx.Colour `_ .. seealso:: `SetColour <#SetColour>`_ -------- .. method:: GetDashCount() `No docstrings available for this method.` -------- .. method:: GetDashes() Gets an array of dashes (defined as char in X, DWORD under Windows). The function returns the number of dashes associated with this pen. | **Returns:** `list of integers` .. seealso:: `SetDashes <#SetDashes>`_ -------- .. method:: GetJoin() Returns the pen join style, which may be one of ``wx.JOIN_BEVEL``, ``wx.JOIN_ROUND`` and ``wx.JOIN_MITER``. The default is ``wx.JOIN_ROUND``. | **Returns:** `int` .. seealso:: `SetJoin <#SetJoin>`_ -------- .. method:: GetStipple() Gets a pointer to the stipple bitmap. | **Returns:** `wx.Bitmap `_ .. seealso:: `SetStipple <#SetStipple>`_ -------- .. method:: GetStyle() Returns the pen style. | **Returns:** `int` .. seealso:: `SetStyle <#SetStyle>`_ -------- .. method:: GetWidth() Returns the pen width. | **Returns:** `int` .. seealso:: `SetWidth <#SetWidth>`_ -------- .. method:: IsOk() Returns ``True`` if the pen is initialised. | **Returns:** `bool` -------- .. method:: SetCap(capStyle) Sets the pen cap style, which can be one of ``wx.CAP_ROUND``, ``wx.CAP_PROJECTING`` and ``wx.CAP_BUTT``. **Parameters:** * `capStyle` (int) .. seealso:: `GetCap <#GetCap>`_ -------- .. method:: SetColour(colour) The pen's colour is changed to the given colour. **Parameters:** * `colour` (`wx.Colour `_) .. seealso:: `GetColour <#GetColour>`_ -------- .. method:: SetDashes(dashes) Associates an array of pointers to dashes (defined as char in X, DWORD under Windows) with the pen. The array is not deallocated by `wx.Pen`, but neither must it be deallocated by the calling application until the pen is deleted or this function is called with a ``None`` array. **Parameters:** * `dashes` (list of integers) .. seealso:: `GetDashes <#GetDashes>`_ -------- .. method:: SetJoin(join_style) Sets the pen join style, which may be one of ``wx.JOIN_BEVEL``, ``wx.JOIN_ROUND`` and ``wx.JOIN_MITER``. **Parameters:** * `join_style` (int) .. seealso:: `GetJoin <#GetJoin>`_ -------- .. method:: SetStipple(stipple) Sets the bitmap for stippling. **Parameters:** * `stipple` (`wx.Bitmap `_) .. seealso:: `GetStipple <#GetStipple>`_ -------- .. method:: SetStyle(style) Set the pen style. **Parameters:** * `style` (int) -------- .. method:: SetWidth(width) Sets the pen width. **Parameters:** * `width` (int) .. seealso:: `GetWidth <#GetWidth>`_ -------- Properties ^^^^^^^^^^ .. attribute:: Cap See `GetCap <#GetCap>`_ and `SetCap <#SetCap>`_ .. attribute:: Colour See `GetColour <#GetColour>`_ and `SetColour <#SetColour>`_ .. attribute:: DashCount See `GetDashCount <#GetDashCount>`_ .. attribute:: Dashes See `GetDashes <#GetDashes>`_ and `SetDashes <#SetDashes>`_ .. attribute:: Join See `GetJoin <#GetJoin>`_ and `SetJoin <#SetJoin>`_ .. attribute:: Stipple See `GetStipple <#GetStipple>`_ and `SetStipple <#SetStipple>`_ .. attribute:: Style See `GetStyle <#GetStyle>`_ and `SetStyle <#SetStyle>`_ .. attribute:: Width See `GetWidth <#GetWidth>`_ and `SetWidth <#SetWidth>`_