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
|
.. 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.dataview.DataViewCustomRenderer:
==========================================================================================================================================
|phoenix_title| **wx.dataview.DataViewCustomRenderer**
==========================================================================================================================================
You need to derive a new class from :ref:`wx.dataview.DataViewCustomRenderer` in order to write a new renderer.
You need to override at least :meth:`wx.dataview.DataViewRenderer.SetValue` , :meth:`wx.dataview.DataViewRenderer.GetValue` , :meth:`wx.dataview.DataViewCustomRenderer.GetSize` and :meth:`wx.dataview.DataViewCustomRenderer.Render` .
If you want your renderer to support in-place editing then you also need to override :meth:`wx.dataview.DataViewCustomRenderer.HasEditorCtrl` , :meth:`wx.dataview.DataViewCustomRenderer.CreateEditorCtrl` and :meth:`wx.dataview.DataViewCustomRenderer.GetValueFromEditorCtrl` .
Note that a special event handler will be pushed onto that editor control which handles <``ENTER``> and focus out events in order to end the editing.
|
|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>DataViewCustomRenderer</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.DataViewCustomRenderer_inheritance.png" alt="Inheritance diagram of DataViewCustomRenderer" 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.dataview.DataViewRenderer.html" title="wx.dataview.DataViewRenderer" alt="" coords="29,83,248,112"/> <area shape="rect" id="node3" href="wx.dataview.DataViewCustomRenderer.html" title="wx.dataview.DataViewCustomRenderer" alt="" coords="5,160,272,189"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="97,5,179,35"/> </map>
</p>
|
|sub_classes| Known Subclasses
==============================
:ref:`wx.dataview.DataViewSpinRenderer`
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.dataview.DataViewCustomRenderer.__init__` Constructor.
:meth:`~wx.dataview.DataViewCustomRenderer.Activate` Override this to react to the activation of a cell.
:meth:`~wx.dataview.DataViewCustomRenderer.ActivateCell` Override this to react to cell `activation`.
:meth:`~wx.dataview.DataViewCustomRenderer.CreateEditorCtrl` Override this to create the actual editor control once editing is about to start.
:meth:`~wx.dataview.DataViewCustomRenderer.GetAttr` Return the attribute to be used for rendering.
:meth:`~wx.dataview.DataViewCustomRenderer.GetSize` Return size required to show content.
:meth:`~wx.dataview.DataViewCustomRenderer.GetTextExtent` Helper for :meth:`~DataViewCustomRenderer.GetSize` implementations, respects attributes.
:meth:`~wx.dataview.DataViewCustomRenderer.GetValueFromEditorCtrl` Override this so that the renderer can get the value from the editor control (pointed to by `editor`)
:meth:`~wx.dataview.DataViewCustomRenderer.HasEditorCtrl` Override this and make it return ``True`` in order to indicate that this renderer supports in-place editing.
:meth:`~wx.dataview.DataViewCustomRenderer.LeftClick` Override this to react to a left click.
:meth:`~wx.dataview.DataViewCustomRenderer.Render` Override this to render the cell.
:meth:`~wx.dataview.DataViewCustomRenderer.RenderText` This method should be called from within :meth:`~DataViewCustomRenderer.Render` whenever you need to render simple text.
:meth:`~wx.dataview.DataViewCustomRenderer.StartDrag` Override this to start a drag operation.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.dataview.DataViewCustomRenderer.Attr` See :meth:`~wx.dataview.DataViewCustomRenderer.GetAttr`
:attr:`~wx.dataview.DataViewCustomRenderer.Size` See :meth:`~wx.dataview.DataViewCustomRenderer.GetSize`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.dataview.DataViewCustomRenderer(DataViewRenderer)
**Possible constructors**::
DataViewCustomRenderer(varianttype="string", mode=DATAVIEW_CELL_INERT,
align=DVR_DEFAULT_ALIGNMENT)
You need to derive a new class from DataViewCustomRenderer in order
to write a new renderer.
.. method:: __init__(self, varianttype="string", mode=DATAVIEW_CELL_INERT, align=DVR_DEFAULT_ALIGNMENT)
Constructor.
:param `varianttype`:
:type `varianttype`: string
:param `mode`:
:type `mode`: wx.dataview.DataViewCellMode
:param `align`:
:type `align`: int
.. method:: Activate(self, cell, model, item, col)
Override this to react to the activation of a cell.
This method is deprecated, please use ActivateCell instead.
:param `cell`:
:type `cell`: wx.Rect
:param `model`:
:type `model`: wx.dataview.DataViewModel
:param `item`:
:type `item`: wx.dataview.DataViewItem
:param `col`:
:type `col`: int
:rtype: `bool`
.. method:: ActivateCell(self, cell, model, item, col, mouseEvent)
Override this to react to cell `activation`.
Activating a cell is an alternative to showing inline editor when the value can be edited in a simple way that doesn't warrant full editor control. The most typical use of cell activation is toggling the checkbox in :ref:`wx.dataview.DataViewToggleRenderer`; others would be e.g. an embedded volume slider or a five-star rating column.
The exact means of activating a cell are platform-dependent, but they are usually similar to those used for inline editing of values. Typically, a cell would be activated by Space or Enter keys or by left mouse click.
This method will only be called if the cell has the ``wx.dataview.DATAVIEW_CELL_ACTIVATABLE`` mode.
:param `cell`: Coordinates of the activated cell's area.
:type `cell`: wx.Rect
:param `model`: The model to manipulate in response.
:type `model`: wx.dataview.DataViewModel
:param `item`: Activated item.
:type `item`: wx.dataview.DataViewItem
:param `col`: Activated column of `item`.
:type `col`: int
:param `mouseEvent`: If the activation was triggered by mouse click, contains the corresponding event. Is ``None`` otherwise (for keyboard activation). Mouse coordinates are adjusted to be relative to the cell.
:type `mouseEvent`: wx.MouseEvent
:rtype: `bool`
.. versionadded:: 2.9.3
.. note::
Do not confuse this method with item activation in :ref:`wx.dataview.DataViewCtrl` and the wxEVT_DATAVIEW_ITEM_ACTIVATED event. That one is used for activating the item (or, to put it differently, the entire row) similarly to analogous messages in :ref:`wx.TreeCtrl` and :ref:`wx.ListCtrl`, and the effect differs (play a song, open a file etc.). Cell activation, on the other hand, is all about interacting with the individual cell.
.. seealso:: :meth:`CreateEditorCtrl`
.. method:: CreateEditorCtrl(self, parent, labelRect, value)
Override this to create the actual editor control once editing is about to start.
This method will only be called if the cell has the ``wx.dataview.DATAVIEW_CELL_EDITABLE`` mode. Editing is typically triggered by slowly double-clicking the cell or by a platform-dependent keyboard shortcut (``F2`` is typical on Windows, Space and/or Enter is common elsewhere and supported on Windows too).
:param `parent`: The parent of the editor control.
:type `parent`: wx.Window
:param `labelRect`: Indicates the position and size of the editor control. The control should be created in place of the cell and `labelRect` should be respected as much as possible.
:type `labelRect`: wx.Rect
:param `value`: Initial value of the editor.
:type `value`: DVCVariant
:rtype: :ref:`Window`
::
# Some integer...
l = value
return wx.SpinCtrl(parent, wx.ID_ANY, "",
labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l)
.. seealso:: :meth:`ActivateCell`
.. method:: GetAttr(self)
Return the attribute to be used for rendering.
This function may be called from :meth:`Render` implementation to use the attributes defined for the item if the renderer supports them.
Notice that when :meth:`Render` is called, the :ref:`wx.DC` object passed to it is already set up to use the correct attributes (e.g. its font is set to bold or italic version if :meth:`wx.dataview.DataViewItemAttr.GetBold` or GetItalic() returns ``True``) so it may not be necessary to call it explicitly if you only want to render text using the items attributes.
:rtype: :ref:`wx.dataview.DataViewItemAttr`
.. versionadded:: 2.9.1
.. method:: GetSize(self)
Return size required to show content.
:rtype: :ref:`Size`
.. method:: GetTextExtent(self, str)
Helper for :meth:`GetSize` implementations, respects attributes.
:param `str`:
:type `str`: string
:rtype: :ref:`Size`
.. method:: GetValueFromEditorCtrl(self, editor)
Override this so that the renderer can get the value from the editor control (pointed to by `editor`):
::
# sc is a wx.SpinCtrl
l = sc.GetValue()
value = l
return True
:param `editor`:
:type `editor`: wx.Window
:rtype: `value`
.. method:: HasEditorCtrl(self)
Override this and make it return ``True`` in order to indicate that this renderer supports in-place editing.
:rtype: `bool`
.. method:: LeftClick(self, cursor, cell, model, item, col)
Override this to react to a left click.
This method will only be called in ``DATAVIEW_CELL_ACTIVATABLE`` mode. This method is deprecated, please use ActivateCell instead.
:param `cursor`:
:type `cursor`: wx.Point
:param `cell`:
:type `cell`: wx.Rect
:param `model`:
:type `model`: wx.dataview.DataViewModel
:param `item`:
:type `item`: wx.dataview.DataViewItem
:param `col`:
:type `col`: int
:rtype: `bool`
.. method:: Render(self, cell, dc, state)
Override this to render the cell.
Before this is called, :meth:`wx.dataview.DataViewRenderer.SetValue` was called so that this instance knows what to render.
:param `cell`:
:type `cell`: wx.Rect
:param `dc`:
:type `dc`: wx.DC
:param `state`:
:type `state`: int
:rtype: `bool`
.. method:: RenderText(self, text, xoffset, cell, dc, state)
This method should be called from within :meth:`Render` whenever you need to render simple text.
This will ensure that the correct colour, font and vertical alignment will be chosen so the text will look the same as text drawn by native renderers.
:param `text`:
:type `text`: string
:param `xoffset`:
:type `xoffset`: int
:param `cell`:
:type `cell`: wx.Rect
:param `dc`:
:type `dc`: wx.DC
:param `state`:
:type `state`: int
.. method:: StartDrag(self, cursor, cell, model, item, col)
Override this to start a drag operation.
Not yet supported.
:param `cursor`:
:type `cursor`: wx.Point
:param `cell`:
:type `cell`: wx.Rect
:param `model`:
:type `model`: wx.dataview.DataViewModel
:param `item`:
:type `item`: wx.dataview.DataViewItem
:param `col`:
:type `col`: int
:rtype: `bool`
.. attribute:: Attr
See :meth:`~wx.dataview.DataViewCustomRenderer.GetAttr`
.. attribute:: Size
See :meth:`~wx.dataview.DataViewCustomRenderer.GetSize`
|