File: wx.lib.mixins.treemixin.VirtualTree.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 (291 lines) | stat: -rw-r--r-- 11,934 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
.. 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

.. currentmodule:: wx.lib.mixins.treemixin

.. highlight:: python



.. _wx.lib.mixins.treemixin.VirtualTree:

==========================================================================================================================================
|phoenix_title|  **wx.lib.mixins.treemixin.VirtualTree**
==========================================================================================================================================

This is a mixin class that can be used to allow for virtual tree
controls. It can be mixed in with wx.TreeCtrl, wx.gizmos.TreeListCtrl,
wx.lib.customtree.CustomTreeCtrl.

To use it derive a new class from this class and one of the tree
controls, e.g.::

  class MyTree(VirtualTree, wx.TreeCtrl):
      # Other code here


VirtualTree uses several callbacks (such as OnGetItemText) to
retrieve information needed to construct the tree and render the
items. To specify what item the callback needs information about,
the callback passes an item index. Whereas for list controls a simple
integer index can be used, for tree controls indicating a specific
item is a little bit more complicated. See below for a more detailed
explanation of the how index works.

Note that VirtualTree forces the wx.TR_HIDE_ROOT style.

In your subclass you *must* override OnGetItemText and
OnGetChildrenCount. These two methods are the minimum needed to
construct the tree and render the item labels. If you want to add
images, change fonts our colours, etc., you need to override the
appropriate OnGetXXX method as well.

About indices: your callbacks are passed a tuple of integers that
identifies the item the VirtualTree wants information about. An
empty tuple, i.e. (), represents the hidden root item.  A tuple with
one integer, e.g. (3,), represents a visible root item, in this case
the fourth one. A tuple with two integers, e.g. (3,0), represents a
child of a visible root item, in this case the first child of the
fourth root item.



|

|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>VirtualTree</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.lib.mixins.treemixin.VirtualTree_inheritance.png" alt="Inheritance diagram of VirtualTree" 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.lib.mixins.treemixin.TreeAPIHarmonizer.html" title="wx.lib.mixins.treemixin.TreeAPIHarmonizer" alt="" coords="5,5,296,35"/> <area shape="rect" id="node3" href="wx.lib.mixins.treemixin.VirtualTree.html" title="wx.lib.mixins.treemixin.VirtualTree" alt="" coords="177,83,412,112"/> <area shape="rect" id="node2" href="wx.lib.mixins.treemixin.TreeHelper.html" title="wx.lib.mixins.treemixin.TreeHelper" alt="" coords="320,5,556,35"/> </map> 
   </p>

|


|super_classes| Known Superclasses
==================================

:class:`wx.lib.mixins.treemixin.TreeAPIHarmonizer`, :class:`wx.lib.mixins.treemixin.TreeHelper`

|


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

================================================================================ ================================================================================
:meth:`~wx.lib.mixins.treemixin.VirtualTree.__init__`                            
:meth:`~wx.lib.mixins.treemixin.VirtualTree.ChildIndices`                        
:meth:`~wx.lib.mixins.treemixin.VirtualTree.DoRefreshItem`                       Refresh one item.
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnGetChildrenCount`                  This function *must* be overloaded in the derived class.
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnGetItemBackgroundColour`           This function may be overloaded in the derived class. It
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnGetItemChecked`                    This function may be overloaded in the derived class, but
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnGetItemFont`                       This function may be overloaded in the derived class. It
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnGetItemImage`                      This function may be overloaded in the derived class. It
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnGetItemText`                       This function *must* be overloaded in the derived class. It
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnGetItemTextColour`                 This function may be overloaded in the derived class. It
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnGetItemType`                       This function may be overloaded in the derived class, but
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnItemCollapsed`                     
:meth:`~wx.lib.mixins.treemixin.VirtualTree.OnItemExpanding`                     
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshBackgroundColour`             
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshCheckedState`                 
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshChildrenRecursively`          Refresh the children of item, reusing as much of the
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshColumns`                      
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshItem`                         Redraws the item with the specified index.
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshItemFont`                     
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshItemImage`                    
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshItemRecursively`              Refresh the item and its children recursively.
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshItems`                        Redraws all visible items.
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshItemText`                     
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshItemType`                     
:meth:`~wx.lib.mixins.treemixin.VirtualTree.RefreshTextColour`                   
================================================================================ ================================================================================


|


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


.. class:: VirtualTree(TreeAPIHarmonizer, TreeHelper)

   This is a mixin class that can be used to allow for virtual tree
   controls. It can be mixed in with wx.TreeCtrl, wx.gizmos.TreeListCtrl,
   wx.lib.customtree.CustomTreeCtrl.
   
   To use it derive a new class from this class and one of the tree
   controls, e.g.::
   
     class MyTree(VirtualTree, wx.TreeCtrl):
         # Other code here
   
   
   VirtualTree uses several callbacks (such as OnGetItemText) to
   retrieve information needed to construct the tree and render the
   items. To specify what item the callback needs information about,
   the callback passes an item index. Whereas for list controls a simple
   integer index can be used, for tree controls indicating a specific
   item is a little bit more complicated. See below for a more detailed
   explanation of the how index works.
   
   Note that VirtualTree forces the wx.TR_HIDE_ROOT style.
   
   In your subclass you *must* override OnGetItemText and
   OnGetChildrenCount. These two methods are the minimum needed to
   construct the tree and render the item labels. If you want to add
   images, change fonts our colours, etc., you need to override the
   appropriate OnGetXXX method as well.
   
   About indices: your callbacks are passed a tuple of integers that
   identifies the item the VirtualTree wants information about. An
   empty tuple, i.e. (), represents the hidden root item.  A tuple with
   one integer, e.g. (3,), represents a visible root item, in this case
   the fourth one. A tuple with two integers, e.g. (3,0), represents a
   child of a visible root item, in this case the first child of the
   fourth root item.

   .. method:: __init__(self, \*args, \*\*kwargs)


   .. method:: ChildIndices(self, itemIndex)


   .. method:: DoRefreshItem(self, item, index, hasChildren)

      Refresh one item. 


   .. method:: OnGetChildrenCount(self, index)

      This function *must* be overloaded in the derived class.
      It should return the number of child items of the item with the
      provided index. If index == () it should return the number of
      root items. 


   .. method:: OnGetItemBackgroundColour(self, index)

      This function may be overloaded in the derived class. It
      should return the wx.Colour to be used as background colour for
      the specified item. 


   .. method:: OnGetItemChecked(self, index)

      This function may be overloaded in the derived class, but
      that only makes sense when this class is mixed in with a tree
      control that supports checkable items, i.e. CustomTreeCtrl.
      This method should return whether the item is to be checked.
      Note that OnGetItemType should return 1 (checkbox) or 2
      (radiobutton) for this item. 


   .. method:: OnGetItemFont(self, index)

      This function may be overloaded in the derived class. It
      should return the wx.Font to be used for the specified item. 


   .. method:: OnGetItemImage(self, index, which=wx.TreeItemIcon_Normal, column=0)

      This function may be overloaded in the derived class. It
      should return the index of the image to be used. Don't forget
      to associate an ImageList with the tree control. 


   .. method:: OnGetItemText(self, index, column=0)

      This function *must* be overloaded in the derived class. It
      should return the string containing the text of the specified
      item. 


   .. method:: OnGetItemTextColour(self, index)

      This function may be overloaded in the derived class. It
      should return the wx.Colour to be used as text colour for the
      specified item. 


   .. method:: OnGetItemType(self, index)

      This function may be overloaded in the derived class, but
      that only makes sense when this class is mixed in with a tree
      control that supports checkable items, i.e. CustomTreeCtrl.
      This method should return whether the item is to be normal (0,
      the default), a checkbox (1) or a radiobutton (2).
      Note that OnGetItemChecked needs to be implemented as well; it
      should return whether the item is actually checked. 


   .. method:: OnItemCollapsed(self, event)


   .. method:: OnItemExpanding(self, event)


   .. method:: RefreshBackgroundColour(self, item, index)


   .. method:: RefreshCheckedState(self, item, index)


   .. method:: RefreshChildrenRecursively(self, item, itemIndex=None)

      Refresh the children of item, reusing as much of the
      existing items in the tree as possible. 


   .. method:: RefreshColumns(self, item, index)


   .. method:: RefreshItem(self, index)

      Redraws the item with the specified index. 


   .. method:: RefreshItemFont(self, item, index)


   .. method:: RefreshItemImage(self, item, index, hasChildren)


   .. method:: RefreshItemRecursively(self, item, itemIndex)

      Refresh the item and its children recursively. 


   .. method:: RefreshItems(self)

      Redraws all visible items. 


   .. method:: RefreshItemText(self, item, index)


   .. method:: RefreshItemType(self, item, index)


   .. method:: RefreshTextColour(self, item, index)