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.
Do not initialize objects on the stack before the program commences, since other required structures may not have been set up yet. Instead, define global pointers to objects and create them in wx.App.OnInit
or when required.
An application may wish to dynamically create pens with different 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 wx.PenList.FindOrCreatePen
. See wx.PenList for more info.
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.
Note
On a monochrome display, wxWidgets shows all non-white pens as black.
See also
wx.PenList, wx.DC, wx.DC.SetPen
Default constructor. |
|
Returns the pen cap style, which may be one of |
|
Returns a reference to the pen colour. |
|
Gets an array of dashes (defined as |
|
Returns the pen join style, which may be one of |
|
Returns the pen quality. |
|
Gets a pointer to the stipple bitmap. |
|
Returns the pen style. |
|
Returns the pen width. |
|
Returns |
|
Returns |
|
Returns |
|
Sets the pen cap style, which may be one of |
|
The pen’s colour is changed to the given colour. |
|
Associates an array of dash values (defined as |
|
Sets the pen join style, which may be one of |
|
Sets the pen quality. |
|
Sets the bitmap for stippling. |
|
Set the pen style. |
|
Sets the pen width. |
|
For internal use only. |
|
Inequality operator. |
|
Equality operator. |
See |
|
See |
|
wx.
Pen
(GDIObject)¶Possible constructors:
Pen()
Pen(info)
Pen(colour, width=1, style=PENSTYLE_SOLID)
Pen(pen)
A pen is a drawing tool for drawing outlines.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
The pen will be uninitialised, and IsOk
will return False
.
__init__ (self, info)
Creates a pen object using the specified pen description.
info (wx.PenInfo) –
__init__ (self, colour, width=1, style=PENSTYLE_SOLID)
Constructs a pen from a colour object, pen width and style.
colour (wx.Colour) – A colour object.
width (int) – Pen width. Under Windows, the pen width cannot be greater than 1 if the style is PENSTYLE_DOT
, PENSTYLE_LONG_DASH
, PENSTYLE_SHORT_DASH
, PENSTYLE_DOT_DASH
, or PENSTYLE_USER_DASH
.
style (PenStyle) – The style may be one of the wx.PenStyle values.
Note
Different versions of Windows and different versions of other platforms support very different subsets of the styles above so handle with care.
See also
SetStyle
, SetColour
, SetWidth
__init__ (self, pen)
Copy constructor, uses Reference Counting.
pen (wx.Pen) – A pointer or reference to a pen to copy.
GetCap
(self)¶Returns the pen cap style, which may be one of CAP_ROUND
, CAP_PROJECTING
and CAP_BUTT
.
The default is CAP_ROUND
.
See also
GetDashes
(self)¶Gets an array of dashes (defined as char
in X, DWORD
under Windows).
dashes is a pointer to the internal array. Do not deallocate or store this pointer.
list of integers
The number of dashes associated with this pen.
See also
GetJoin
(self)¶Returns the pen join style, which may be one of JOIN_BEVEL
, JOIN_ROUND
and JOIN_MITER
.
The default is JOIN_ROUND
.
See also
GetQuality
(self)¶Returns the pen quality.
The default is PEN_QUALITY_DEFAULT
.
See also
GetStipple
(self)¶Gets a pointer to the stipple bitmap.
See also
GetStyle
(self)¶Returns the pen style.
IsNonTransparent
(self)¶Returns True
if the pen is a valid non-transparent pen.
This method returns True
if the pen object is initialized and has a non-transparent style. Notice that this should be used instead of simply testing whether GetStyle
returns a style different from wx.PENSTYLE_TRANSPARENT
if the pen may be invalid as GetStyle
would assert in this case.
bool
New in version 2.9.2..
See also
IsOk
(self)¶Returns True
if the pen is initialised.
Notice that an uninitialized pen object can’t be queried for any pen properties and all calls to the accessor methods on it will result in an assert failure.
bool
IsTransparent
(self)¶Returns True
if the pen is transparent.
A transparent pen is simply a pen with wx.PENSTYLE_TRANSPARENT
style.
Notice that this function works even for non-initialized pens (for which it returns False
) unlike tests of the form GetStyle
== wx.PENSTYLE_TRANSPARENT
which would assert if the pen is invalid.
bool
New in version 2.9.2..
See also
SetCap
(self, capStyle)¶Sets the pen cap style, which may be one of CAP_ROUND
, CAP_PROJECTING
and CAP_BUTT
.
The default is CAP_ROUND
.
capStyle (PenCap) –
See also
SetColour
(self, *args, **kw)¶The pen’s colour is changed to the given colour.
SetDashes
(self, dashes)¶Associates an array of dash values (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.
dashes (list of integers) –
See also
SetJoin
(self, join_style)¶Sets the pen join style, which may be one of JOIN_BEVEL
, JOIN_ROUND
and JOIN_MITER
.
The default is JOIN_ROUND
.
join_style (PenJoin) –
See also
SetQuality
(self, quality)¶Sets the pen quality.
Explicitly selecting low pen quality may be useful in wxMSW if drawing performance is more important than the exact appearance of the lines drawn with this pen.
quality (PenQuality) –
New in version 4.1/wxWidgets-3.1.5.
See also
SetStipple
(self, stipple)¶Sets the bitmap for stippling.
stipple (wx.Bitmap) –
See also
_copyFrom
(self, other)¶For internal use only.
__ne__
(self)¶Inequality operator.
See reference-counted object comparison for more info.
pen (wx.Pen) –
__eq__
(self)¶Equality operator.
See reference-counted object comparison for more info.
pen (wx.Pen) –
Quality
¶See GetQuality
and SetQuality
Stipple
¶See GetStipple
and SetStipple