File: wx.Pen.txt

package info (click to toggle)
wxpython4.0 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 211,112 kB
  • sloc: cpp: 888,355; python: 223,130; makefile: 52,087; ansic: 45,780; sh: 3,012; xml: 1,534; perl: 264
file content (789 lines) | stat: -rw-r--r-- 16,909 bytes parent folder | download
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
.. 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.Pen:

==========================================================================================================================================
|phoenix_title|  **wx.Pen**
==========================================================================================================================================

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  :meth:`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 :ref:`wx.ThePenList`, and calling the member function :meth:`wx.PenList.FindOrCreatePen` . See :ref:`wx.PenList`  for more info. 

This class uses :ref:`reference counting and copy-on-write <reference counting>`  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.  







.. seealso:: :ref:`wx.PenList`, :ref:`wx.DC`, :meth:`wx.DC.SetPen`     







|

|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>Pen</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.Pen_inheritance.png" alt="Inheritance diagram of Pen" 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.Pen.html" title="wx.Pen" alt="" coords="23,160,95,189"/> <area shape="rect" id="node2" href="wx.GDIObject.html" title="wx.GDIObject" alt="" coords="5,83,112,112"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="17,5,99,35"/> </map> 
   </p>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.Pen.__init__`                                                         Default constructor.
:meth:`~wx.Pen.GetCap`                                                           Returns the pen cap style, which may be one of  ``CAP_ROUND`` ,   ``CAP_PROJECTING``   and   ``CAP_BUTT`` .
:meth:`~wx.Pen.GetColour`                                                        Returns a reference to the pen colour.
:meth:`~wx.Pen.GetDashes`                                                        Gets an array of dashes (defined as  ``char``   in X,   ``DWORD``   under Windows).
:meth:`~wx.Pen.GetJoin`                                                          Returns the pen join style, which may be one of  ``JOIN_BEVEL`` ,   ``JOIN_ROUND``   and   ``JOIN_MITER`` .
:meth:`~wx.Pen.GetStipple`                                                       Gets a pointer to the stipple bitmap.
:meth:`~wx.Pen.GetStyle`                                                         Returns the pen style.
:meth:`~wx.Pen.GetWidth`                                                         Returns the pen width.
:meth:`~wx.Pen.IsNonTransparent`                                                 Returns ``True`` if the pen is a valid non-transparent pen.
:meth:`~wx.Pen.IsOk`                                                             Returns ``True`` if the pen is initialised.
:meth:`~wx.Pen.IsTransparent`                                                    Returns ``True`` if the pen is transparent.
:meth:`~wx.Pen.SetCap`                                                           Sets the pen cap style, which may be one of  ``CAP_ROUND`` ,   ``CAP_PROJECTING``   and   ``CAP_BUTT`` .
:meth:`~wx.Pen.SetColour`                                                        The pen's colour is changed to the given colour.
:meth:`~wx.Pen.SetDashes`                                                        Associates an array of dash values (defined as  ``char``   in X,   ``DWORD``   under Windows) with the pen.
:meth:`~wx.Pen.SetJoin`                                                          Sets the pen join style, which may be one of  ``JOIN_BEVEL`` ,   ``JOIN_ROUND``   and   ``JOIN_MITER`` .
:meth:`~wx.Pen.SetStipple`                                                       Sets the bitmap for stippling.
:meth:`~wx.Pen.SetStyle`                                                         Set the pen style.
:meth:`~wx.Pen.SetWidth`                                                         Sets the pen width.
:meth:`~wx.Pen._copyFrom`                                                        For internal use only.
:meth:`~wx.Pen.__ne__`                                                           Inequality operator.
:meth:`~wx.Pen.__eq__`                                                           Equality operator.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.Pen.Cap`                                                              See :meth:`~wx.Pen.GetCap` and :meth:`~wx.Pen.SetCap`
:attr:`~wx.Pen.Colour`                                                           See :meth:`~wx.Pen.GetColour` and :meth:`~wx.Pen.SetColour`
:attr:`~wx.Pen.Dashes`                                                           See :meth:`~wx.Pen.GetDashes` and :meth:`~wx.Pen.SetDashes`
:attr:`~wx.Pen.Join`                                                             See :meth:`~wx.Pen.GetJoin` and :meth:`~wx.Pen.SetJoin`
:attr:`~wx.Pen.Stipple`                                                          See :meth:`~wx.Pen.GetStipple` and :meth:`~wx.Pen.SetStipple`
:attr:`~wx.Pen.Style`                                                            See :meth:`~wx.Pen.GetStyle` and :meth:`~wx.Pen.SetStyle`
:attr:`~wx.Pen.Width`                                                            See :meth:`~wx.Pen.GetWidth` and :meth:`~wx.Pen.SetWidth`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.Pen(GDIObject)

   **Possible constructors**::

       Pen()
       
       Pen(colour, width=1, style=PENSTYLE_SOLID)
       
       Pen(pen)
       
   
   A pen is a drawing tool for drawing outlines.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self)`
      
      Default constructor.                  
      
      The pen will be uninitialised, and :meth:`IsOk`   will return ``False``.                   
      
      
      
      
      **~~~**

      
      **__init__** `(self, colour, width=1, style=PENSTYLE_SOLID)`
      
      Constructs a pen from a colour object, pen width and style.                  
      
      
      
      
      :param `colour`: A colour object.   
      :type `colour`: wx.Colour
      :param `width`: 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`` .    
      :type `width`: int
      :param `style`: The style may be one of the :ref:`wx.PenStyle`  values.  
      :type `style`: wx.PenStyle
      
      
      
      
      
      
      
      
                        
      
      
      
      .. note:: 
      
         Different versions of Windows and different versions of other platforms support very different subsets of the styles above
      
         - there is no similarity even between Windows95 and Windows98 - so handle with care. 
      
      
      
      
      
      
      
      
      
      
      .. seealso:: :meth:`SetStyle` , :meth:`SetColour` , :meth:`SetWidth`     
      
      
      
      
      
      
      
      **~~~**

      
      **__init__** `(self, pen)`
      
      Copy constructor, uses :ref:`Reference Counting <reference counting>`.                  
      
      
      
      
      :param `pen`: A pointer or reference to a pen to copy.   
      :type `pen`: wx.Pen
      
      
      
      
                        
      
      
      
      
      **~~~**






   .. method:: GetCap(self)

      Returns the pen cap style, which may be one of  ``CAP_ROUND`` ,   ``CAP_PROJECTING``   and   ``CAP_BUTT`` .                   

      The default is  ``CAP_ROUND`` . 

                

      :rtype: :ref:`wx.PenCap`







      .. seealso:: :meth:`SetCap`     








   .. method:: GetColour(self)

      Returns a reference to the pen colour.                  

                

      :rtype: :ref:`wx.Colour`







      .. seealso:: :meth:`SetColour`     








   .. method:: 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. 

                

      :rtype: `list of integers`







      :returns: 

         The number of dashes associated with this pen.  







      .. seealso:: :meth:`SetDashes`     








   .. method:: GetJoin(self)

      Returns the pen join style, which may be one of  ``JOIN_BEVEL`` ,   ``JOIN_ROUND``   and   ``JOIN_MITER`` .                   

      The default is  ``JOIN_ROUND`` . 

                

      :rtype: :ref:`wx.PenJoin`







      .. seealso:: :meth:`SetJoin`     








   .. method:: GetStipple(self)

      Gets a pointer to the stipple bitmap.                  

                

      :rtype: :ref:`wx.Bitmap`







      .. seealso:: :meth:`SetStipple`     








   .. method:: GetStyle(self)

      Returns the pen style.                  

                

      :rtype: :ref:`wx.PenStyle`







      .. seealso:: :ref:`wx.Pen`, :meth:`SetStyle`     








   .. method:: GetWidth(self)

      Returns the pen width.                  

                

      :rtype: `int`







      .. seealso:: :meth:`SetWidth`     








   .. method:: 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 :meth:`GetStyle`   returns a style different from ``wx.PENSTYLE_TRANSPARENT`` if the pen may be invalid as :meth:`GetStyle`   would assert in this case. 

                

      :rtype: `bool`







      .. versionadded:: 2.9.2.
      







      .. seealso:: :meth:`IsTransparent`   








   .. method:: 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.                  

      :rtype: `bool`








   .. method:: 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  :meth:`GetStyle`   == ``wx.PENSTYLE_TRANSPARENT``  which would assert if the pen is invalid. 

                

      :rtype: `bool`







      .. versionadded:: 2.9.2.
      







      .. seealso:: :meth:`IsNonTransparent`   








   .. method:: 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`` . 

                


      :param `capStyle`: 
      :type `capStyle`: wx.PenCap






      .. seealso:: :meth:`GetCap`     








   .. method:: SetColour(self, *args, **kw)

      The pen's colour is changed to the given colour.                  

                 



      .. seealso:: :meth:`GetColour`     





      |overload| Overloaded Implementations:

      **~~~**

      
      **SetColour** `(self, colour)`
      
      
      
      
      :param `colour`: 
      :type `colour`: wx.Colour
      
      
      
      
      
      
      **~~~**

      
      **SetColour** `(self, red, green, blue)`
      
      
      
      
      :param `red`: 
      :type `red`: int
      :param `green`: 
      :type `green`: int
      :param `blue`: 
      :type `blue`: int
      
      
      
      
      
      
      **~~~**






   .. method:: 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 :ref:`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. 

                


      :param `dashes`: 
      :type `dashes`: list of integers






      .. seealso:: :meth:`GetDashes`     








   .. method:: 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`` . 

                


      :param `join_style`: 
      :type `join_style`: wx.PenJoin






      .. seealso:: :meth:`GetJoin`     








   .. method:: SetStipple(self, stipple)

      Sets the bitmap for stippling.                  

                


      :param `stipple`: 
      :type `stipple`: wx.Bitmap






      .. seealso:: :meth:`GetStipple`     








   .. method:: SetStyle(self, style)

      Set the pen style.                  

                


      :param `style`: 
      :type `style`: wx.PenStyle






      .. seealso:: :ref:`wx.Pen`    








   .. method:: SetWidth(self, width)

      Sets the pen width.                  

                


      :param `width`: 
      :type `width`: int






      .. seealso:: :meth:`GetWidth`     








   .. method:: _copyFrom(self, other)

      For internal use only.  





   .. method:: __ne__(self)

      Inequality operator.                  

      See :ref:`reference-counted object comparison <reference-counted object comparison>`  for more info.                  


      :param `pen`: 
      :type `pen`: wx.Pen







   .. method:: __eq__(self)

      Equality operator.                  

      See :ref:`reference-counted object comparison <reference-counted object comparison>`  for more info.                  


      :param `pen`: 
      :type `pen`: wx.Pen







   .. attribute:: Cap

      See :meth:`~wx.Pen.GetCap` and :meth:`~wx.Pen.SetCap`


   .. attribute:: Colour

      See :meth:`~wx.Pen.GetColour` and :meth:`~wx.Pen.SetColour`


   .. attribute:: Dashes

      See :meth:`~wx.Pen.GetDashes` and :meth:`~wx.Pen.SetDashes`


   .. attribute:: Join

      See :meth:`~wx.Pen.GetJoin` and :meth:`~wx.Pen.SetJoin`


   .. attribute:: Stipple

      See :meth:`~wx.Pen.GetStipple` and :meth:`~wx.Pen.SetStipple`


   .. attribute:: Style

      See :meth:`~wx.Pen.GetStyle` and :meth:`~wx.Pen.SetStyle`


   .. attribute:: Width

      See :meth:`~wx.Pen.GetWidth` and :meth:`~wx.Pen.SetWidth`