.. wxPython Phoenix documentation

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

   Copyright: (c) 2011-2017 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.TreeHelper.html" title="wx.lib.mixins.treemixin.TreeHelper" alt="" coords="5,5,241,35"/> <area shape="rect" id="node2" href="wx.lib.mixins.treemixin.VirtualTree.html" title="wx.lib.mixins.treemixin.VirtualTree" alt="" coords="150,83,385,112"/> <area shape="rect" id="node3" href="wx.lib.mixins.treemixin.TreeAPIHarmonizer.html" title="wx.lib.mixins.treemixin.TreeAPIHarmonizer" alt="" coords="267,5,557,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)


