File: wx.dataview.DataViewRenderer.txt

package info (click to toggle)
wxpython4.0 4.2.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 232,540 kB
  • sloc: cpp: 958,937; python: 233,059; ansic: 150,441; makefile: 51,662; sh: 8,687; perl: 1,563; javascript: 584; php: 326; xml: 200
file content (633 lines) | stat: -rw-r--r-- 16,497 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
.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.dataview.DataViewRenderer:

==========================================================================================================================================
|phoenix_title|  **wx.dataview.DataViewRenderer**
==========================================================================================================================================

This class is used by :ref:`wx.dataview.DataViewCtrl`  to render the individual cells.          

One instance of a renderer class is owned by a :ref:`wx.dataview.DataViewColumn`. There is a number of ready-to-use renderers provided:

- :ref:`wx.dataview.DataViewTextRenderer`, 
- :ref:`wx.dataview.DataViewIconTextRenderer`, 
- :ref:`wx.dataview.DataViewCheckIconTextRenderer`, 
- :ref:`wx.dataview.DataViewToggleRenderer`, 
- :ref:`wx.dataview.DataViewProgressRenderer`, 
- :ref:`wx.dataview.DataViewBitmapRenderer`, 
- :ref:`wx.dataview.DataViewDateRenderer`, 
- :ref:`wx.dataview.DataViewSpinRenderer`. 
- :ref:`wx.dataview.DataViewChoiceRenderer`. 




Additionally, the user can write their own renderers by deriving from :ref:`wx.dataview.DataViewCustomRenderer`. 

The :ref:`wx.dataview.DataViewCellMode`  and :ref:`wx.dataview.DataViewCellRenderState`  flags accepted by the constructors respectively controls what actions the cell data allows and how the renderer should display its contents in a cell. 







|

|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>DataViewRenderer</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.dataview.DataViewRenderer_inheritance.png" alt="Inheritance diagram of DataViewRenderer" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.dataview.DataViewRenderer.html" title="wx.dataview.DataViewRenderer" alt="" coords="5,83,235,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="77,5,163,35"/> </map> 
   </p>
   </div>

|


|sub_classes| Known Subclasses
==============================

:ref:`wx.dataview.DataViewBitmapRenderer`, :ref:`wx.dataview.DataViewCheckIconTextRenderer`, :ref:`wx.dataview.DataViewChoiceRenderer`, :ref:`wx.dataview.DataViewCustomRenderer`, :ref:`wx.dataview.DataViewDateRenderer`, :ref:`wx.dataview.DataViewIconTextRenderer`, :ref:`wx.dataview.DataViewProgressRenderer`, :ref:`wx.dataview.DataViewTextRenderer`, :ref:`wx.dataview.DataViewToggleRenderer`

|


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

================================================================================ ================================================================================
:meth:`~wx.dataview.DataViewRenderer.__init__`                                   Constructor.
:meth:`~wx.dataview.DataViewRenderer.CancelEditing`                              
:meth:`~wx.dataview.DataViewRenderer.CreateEditorCtrl`                           
:meth:`~wx.dataview.DataViewRenderer.DisableEllipsize`                           Disable replacing parts of the item text with ellipsis.
:meth:`~wx.dataview.DataViewRenderer.EnableEllipsize`                            Enable or disable replacing parts of the item text with ellipsis to make it fit the column width.
:meth:`~wx.dataview.DataViewRenderer.FinishEditing`                              
:meth:`~wx.dataview.DataViewRenderer.GetAlignment`                               Returns the alignment.
:meth:`~wx.dataview.DataViewRenderer.GetEditorCtrl`                              
:meth:`~wx.dataview.DataViewRenderer.GetEllipsizeMode`                           Returns the ellipsize mode used by the renderer.
:meth:`~wx.dataview.DataViewRenderer.GetMode`                                    Returns the cell mode.
:meth:`~wx.dataview.DataViewRenderer.GetOwner`                                   Returns pointer to the owning :ref:`wx.dataview.DataViewColumn`.
:meth:`~wx.dataview.DataViewRenderer.GetValue`                                   This methods retrieves the value from the renderer in order to transfer the value back to the data model.
:meth:`~wx.dataview.DataViewRenderer.GetValueFromEditorCtrl`                     
:meth:`~wx.dataview.DataViewRenderer.GetVariantType`                             Returns a string with the type of the :ref:`Variant`  supported by this renderer.
:meth:`~wx.dataview.DataViewRenderer.GetView`                                    
:meth:`~wx.dataview.DataViewRenderer.HasEditorCtrl`                              
:meth:`~wx.dataview.DataViewRenderer.IsCompatibleVariantType`                    Check if the given variant type is compatible with the type expected by this renderer.
:meth:`~wx.dataview.DataViewRenderer.SetAlignment`                               Sets the alignment of the renderer's content.
:meth:`~wx.dataview.DataViewRenderer.SetOwner`                                   Sets the owning :ref:`wx.dataview.DataViewColumn`.
:meth:`~wx.dataview.DataViewRenderer.SetValue`                                   Set the value of the renderer (and thus its cell) to `value`.
:meth:`~wx.dataview.DataViewRenderer.SetValueAdjuster`                           Set the transformer object to be used to customize values before they are rendered.
:meth:`~wx.dataview.DataViewRenderer.StartEditing`                               
:meth:`~wx.dataview.DataViewRenderer.Validate`                                   Before data is committed to the data model, it is passed to this method where it can be checked for validity.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.dataview.DataViewRenderer.Alignment`                                  See :meth:`~wx.dataview.DataViewRenderer.GetAlignment` and :meth:`~wx.dataview.DataViewRenderer.SetAlignment`
:attr:`~wx.dataview.DataViewRenderer.EditorCtrl`                                 See :meth:`~wx.dataview.DataViewRenderer.GetEditorCtrl`
:attr:`~wx.dataview.DataViewRenderer.EllipsizeMode`                              See :meth:`~wx.dataview.DataViewRenderer.GetEllipsizeMode`
:attr:`~wx.dataview.DataViewRenderer.Mode`                                       See :meth:`~wx.dataview.DataViewRenderer.GetMode`
:attr:`~wx.dataview.DataViewRenderer.Owner`                                      See :meth:`~wx.dataview.DataViewRenderer.GetOwner` and :meth:`~wx.dataview.DataViewRenderer.SetOwner`
:attr:`~wx.dataview.DataViewRenderer.VariantType`                                See :meth:`~wx.dataview.DataViewRenderer.GetVariantType`
:attr:`~wx.dataview.DataViewRenderer.View`                                       See :meth:`~wx.dataview.DataViewRenderer.GetView`
================================================================================ ================================================================================


|


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


.. class:: wx.dataview.DataViewRenderer(Object)

   **Possible constructors**::

       DataViewRenderer(varianttype, mode=DATAVIEW_CELL_INERT,
                        align=DVR_DEFAULT_ALIGNMENT)
       
   
   This class is used by DataViewCtrl to render the individual cells.



   .. method:: __init__(self, varianttype, mode=DATAVIEW_CELL_INERT, align=DVR_DEFAULT_ALIGNMENT)

      Constructor.                  

      The `varianttype`  parameter is the main type of :ref:`Variant`  objects supported by this renderer, i.e. those that can be passed to its :meth:`SetValue` , e.g. "string" for :ref:`wx.dataview.DataViewTextRenderer`. The value of this parameter is returned by :meth:`GetVariantType` . 

      When deriving a custom renderer, either an existing variant type or a new custom one can be used, see :ref:`Variant`  documentation for more details.                  


      :param `varianttype`: 
      :type `varianttype`: string
      :param `mode`: 
      :type `mode`: wx.dataview.DataViewCellMode
      :param `align`: 
      :type `align`: int







   .. method:: CancelEditing(self)






   .. method:: CreateEditorCtrl(self, parent, labelRect, value)




      :param `parent`: 
      :type `parent`: wx.Window
      :param `labelRect`: 
      :type `labelRect`: wx.Rect
      :param `value`: 
      :type `value`: DVCVariant




      :rtype: :ref:`Window`








   .. method:: DisableEllipsize(self)

      Disable replacing parts of the item text with ellipsis.                  

      If ellipsizing is disabled, the string will be truncated if it doesn't fit. 

      This is the same as::

           EnableEllipsize(wx.ELLIPSIZE_NONE)



                 



      .. versionadded:: 2.9.1 
     








   .. method:: EnableEllipsize(self, mode=ELLIPSIZE_MIDDLE)

      Enable or disable replacing parts of the item text with ellipsis to make it fit the column width.                  

      This method only makes sense for the renderers working with text, such as :ref:`wx.dataview.DataViewTextRenderer`  or :ref:`wx.dataview.DataViewIconTextRenderer`. 

      By default ``wx.ELLIPSIZE_MIDDLE`` is used. 




      :param `mode`: Ellipsization mode, use ``wx.ELLIPSIZE_NONE`` to disable.  
      :type `mode`: wx.EllipsizeMode




                  



      .. versionadded:: 2.9.1 
     








   .. method:: FinishEditing(self)



      :rtype: `bool`








   .. method:: GetAlignment(self)

      Returns the alignment.                  

      See :meth:`SetAlignment`                    

      :rtype: `int`








   .. method:: GetEditorCtrl(self)



      :rtype: :ref:`Window`








   .. method:: GetEllipsizeMode(self)

      Returns the ellipsize mode used by the renderer.                  

      If the return value is ``wx.ELLIPSIZE_NONE``, the text is simply truncated if it doesn't fit. 

                

      :rtype: :ref:`wx.EllipsizeMode`







      .. seealso:: :meth:`EnableEllipsize`     








   .. method:: GetMode(self)

      Returns the cell mode.                  

      :rtype: :ref:`wx.dataview.DataViewCellMode`








   .. method:: GetOwner(self)

      Returns pointer to the owning :ref:`wx.dataview.DataViewColumn`.                  

      :rtype: :ref:`wx.dataview.DataViewColumn`








   .. method:: GetValue(self)

      This methods retrieves the value from the renderer in order to transfer the value back to the data model.                  

      Returns ``False`` on failure.                  

      :rtype: `value`








   .. method:: GetValueFromEditorCtrl(self, editor)




      :param `editor`: 
      :type `editor`: wx.Window




      :rtype: `value`








   .. method:: GetVariantType(self)

      Returns a string with the type of the :ref:`Variant`  supported by this renderer.                  

      Note that a renderer may support more than one variant type, in which case it needs to override :meth:`IsCompatibleVariantType`   to return ``True``  for all types it supports. But by default only the type returned by this function is supported.                  

      :rtype: `string`








   .. method:: GetView(self)



      :rtype: :ref:`wx.dataview.DataViewCtrl`








   .. method:: HasEditorCtrl(self)



      :rtype: `bool`








   .. method:: IsCompatibleVariantType(self, variantType)

      Check if the given variant type is compatible with the type expected by this renderer.                  

      The base class implementation just compares `variantType`  with the value returned by :meth:`GetVariantType` , but this function can be overridden to accept other types that can be converted to the type needed by the renderer. 

                


      :param `variantType`: 
      :type `variantType`: string




      :rtype: `bool`







      .. versionadded:: 4.1/wxWidgets-3.1.7  
     








   .. method:: SetAlignment(self, align)

      Sets the alignment of the renderer's content.                  

      The default value of  ``DVR_DEFAULT_ALIGNMENT``   indicates that the content should have the same alignment as the column header. 

      The method is not implemented under macOS and the renderer always aligns its contents as the column header on that platform. The other platforms support both vertical and horizontal alignment.                  


      :param `align`: 
      :type `align`: int







   .. method:: SetOwner(self, owner)

      Sets the owning :ref:`wx.dataview.DataViewColumn`.                  

      This is usually called from within :ref:`wx.dataview.DataViewColumn`.                  


      :param `owner`: 
      :type `owner`: wx.dataview.DataViewColumn







   .. method:: SetValue(self, value)

      Set the value of the renderer (and thus its cell) to `value`.                  

      The internal code will then render this cell with this data. 




      :param `value`: A valid, i.e. non-null, value to be shown.   
      :type `value`: :class:`DVCVariant`






      :rtype: `bool`



                  





   .. method:: SetValueAdjuster(self, transformer)

      Set the transformer object to be used to customize values before they are rendered.                  

      Can be used to change the value if it is shown on a highlighted row (i.e. in selection) which typically has dark background. It is useful in combination with :ref:`wx.dataview.DataViewTextRenderer`  with markup and can be used e.g. to remove background color attributes inside selection, as a lightweight alternative to implementing an entire :ref:`wx.dataview.DataViewCustomRenderer`  specialization. 

      `transformer`  can be ``None`` to reset any transformer currently being used. 

      Takes ownership of `transformer`. 

                


      :param `transformer`: 
      :type `transformer`: wx.dataview.DataViewValueAdjuster






      .. versionadded:: 4.1/wxWidgets-3.1.1  
     







      .. seealso:: :ref:`wx.dataview.DataViewValueAdjuster`  








   .. method:: StartEditing(self, item, labelRect)




      :param `item`: 
      :type `item`: wx.dataview.DataViewItem
      :param `labelRect`: 
      :type `labelRect`: wx.Rect




      :rtype: `bool`








   .. method:: Validate(self, value)

      Before data is committed to the data model, it is passed to this method where it can be checked for validity.                  

      This can also be used for checking a valid range or limiting the user input in a certain aspect (e.g. max number of characters or only alphanumeric input, ``ASCII`` only etc.). Return ``False`` if the value is not valid. 

      Please note that due to implementation limitations, this validation is done after the editing control already is destroyed and the editing process finished.                  


      :param `value`: 
      :type `value`: DVCVariant




      :rtype: `bool`








   .. attribute:: Alignment

      See :meth:`~wx.dataview.DataViewRenderer.GetAlignment` and :meth:`~wx.dataview.DataViewRenderer.SetAlignment`


   .. attribute:: EditorCtrl

      See :meth:`~wx.dataview.DataViewRenderer.GetEditorCtrl`


   .. attribute:: EllipsizeMode

      See :meth:`~wx.dataview.DataViewRenderer.GetEllipsizeMode`


   .. attribute:: Mode

      See :meth:`~wx.dataview.DataViewRenderer.GetMode`


   .. attribute:: Owner

      See :meth:`~wx.dataview.DataViewRenderer.GetOwner` and :meth:`~wx.dataview.DataViewRenderer.SetOwner`


   .. attribute:: VariantType

      See :meth:`~wx.dataview.DataViewRenderer.GetVariantType`


   .. attribute:: View

      See :meth:`~wx.dataview.DataViewRenderer.GetView`