1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.PenList:
==========================================================================================================================================
|phoenix_title| **wx.PenList**
==========================================================================================================================================
There is only one instance of this class: :ref:`wx.ThePenList`.
Use this object to search for a previously created pen of the desired type and create it if not already found. In some windowing systems, the pen may be a scarce resource, so it can pay to reuse old resources if possible. When an application finishes, all pens will be deleted and their resources freed, eliminating the possibility of 'memory leaks'. However, it is best not to rely on this automatic cleanup because it can lead to float deletion in some circumstances.
There are two mechanisms in recent versions of wxWidgets which make the pen list less useful than it once was. Under Windows, scarce resources are cleaned up internally if they are not being used. Also, a referencing counting mechanism applied to all GDI objects means that some sharing of underlying resources is possible. You don't have to keep track of pointers, working out when it is safe delete a pen, because the referencing counting does it for you. For example, you can set a pen in a device context, and then immediately delete the pen you passed, because the pen is 'copied'.
So you may find it easier to ignore the pen list, and instead create and copy pens as you see fit. If your Windows resource meter suggests your application is using too many resources, you can resort to using GDI lists to share objects explicitly.
The only compelling use for the pen list is for wxWidgets to keep track of pens in order to clean them up on exit. It is also kept for backward compatibility with earlier versions of wxWidgets.
.. seealso:: :ref:`wx.Pen`
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>PenList</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.PenList_inheritance.png" alt="Inheritance diagram of PenList" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.PenList.html" title="wx.PenList" alt="" coords="5,5,93,35"/> </map>
</p>
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.PenList.__init__` Constructor.
:meth:`~wx.PenList.FindOrCreatePen` Finds a pen with the specified attributes and returns it, else creates a new pen, adds it to the pen list, and returns it.
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.PenList(object)
**Possible constructors**::
PenList()
There is only one instance of this class: ThePenList.
.. method:: __init__(self)
Constructor.
The application should not construct its own pen list: use the object pointer :ref:`wx.ThePenList`.
.. method:: FindOrCreatePen(self, colour, width=1, style=PENSTYLE_SOLID)
Finds a pen with the specified attributes and returns it, else creates a new pen, adds it to the pen list, and returns it.
:param `colour`: Colour object.
:type `colour`: wx.Colour
:param `width`: Width of pen.
:type `width`: int
:param `style`: Pen style. See :ref:`wx.PenStyle` for a list of styles.
:type `style`: wx.PenStyle
:rtype: :ref:`wx.Pen`
|