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
|
.. 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.ExpansionState:
==========================================================================================================================================
|phoenix_title| **wx.lib.mixins.treemixin.ExpansionState**
==========================================================================================================================================
This is a mixin class that can be used to save and restore
the expansion state (i.e. which items are expanded and which items
are collapsed) of a tree. It can be mixed in with wx.TreeCtrl,
wx.gizmos.TreeListCtrl, or wx.lib.customtree.CustomTreeCtrl.
To use it derive a new class from this class and one of the tree
controls, e.g.::
class MyTree(ExpansionState, wx.TreeCtrl):
# Other code here
By default, ExpansionState uses the position of tree items in the tree
to keep track of which items are expanded. This should be sufficient
for the simple scenario where you save the expansion state of the tree
when the user closes the application or file so that you can restore
the expansion state when the user start the application or loads that
file for the next session.
If you need to add or remove items between the moments of saving and
restoring the expansion state (e.g. in case of a multi-user application)
you must override GetItemIdentity so that saving and loading of the
expansion doesn't depend on the position of items in the tree, but
rather on some more stable characteristic of the underlying domain
object, e.g. a social security number in case of persons or an isbn
number in case of books.
|
|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>ExpansionState</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.ExpansionState_inheritance.png" alt="Inheritance diagram of ExpansionState" 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.ExpansionState.html" title="wx.lib.mixins.treemixin.ExpansionState" alt="" coords="160,83,429,112"/> <area shape="rect" id="node2" 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.TreeHelper.html" title="wx.lib.mixins.treemixin.TreeHelper" alt="" coords="320,5,556,35"/> </map>
</p>
|
|sub_classes| Known Subclasses
==============================
:class:`wx.lib.agw.shortcuteditor.ListShortcut`
|
|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.ExpansionState.GetExpansionState` GetExpansionState() -> list of expanded items. Expanded items
:meth:`~wx.lib.mixins.treemixin.ExpansionState.GetExpansionStateOfChildren`
:meth:`~wx.lib.mixins.treemixin.ExpansionState.GetExpansionStateOfItem`
:meth:`~wx.lib.mixins.treemixin.ExpansionState.GetItemIdentity` Return a hashable object that represents the identity of the
:meth:`~wx.lib.mixins.treemixin.ExpansionState.SetExpansionState` SetExpansionState(listOfExpandedItems). Expands all tree items
:meth:`~wx.lib.mixins.treemixin.ExpansionState.SetExpansionStateOfChildren`
:meth:`~wx.lib.mixins.treemixin.ExpansionState.SetExpansionStateOfItem`
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.lib.mixins.treemixin.ExpansionState.ExpansionState` GetExpansionState() -> list of expanded items. Expanded items
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: ExpansionState(TreeAPIHarmonizer, TreeHelper)
This is a mixin class that can be used to save and restore
the expansion state (i.e. which items are expanded and which items
are collapsed) of a tree. It can be mixed in with wx.TreeCtrl,
wx.gizmos.TreeListCtrl, or wx.lib.customtree.CustomTreeCtrl.
To use it derive a new class from this class and one of the tree
controls, e.g.::
class MyTree(ExpansionState, wx.TreeCtrl):
# Other code here
By default, ExpansionState uses the position of tree items in the tree
to keep track of which items are expanded. This should be sufficient
for the simple scenario where you save the expansion state of the tree
when the user closes the application or file so that you can restore
the expansion state when the user start the application or loads that
file for the next session.
If you need to add or remove items between the moments of saving and
restoring the expansion state (e.g. in case of a multi-user application)
you must override GetItemIdentity so that saving and loading of the
expansion doesn't depend on the position of items in the tree, but
rather on some more stable characteristic of the underlying domain
object, e.g. a social security number in case of persons or an isbn
number in case of books.
.. method:: GetExpansionState(self)
GetExpansionState() -> list of expanded items. Expanded items
are coded as determined by the result of GetItemIdentity(item).
.. method:: GetExpansionStateOfChildren(self, item)
.. method:: GetExpansionStateOfItem(self, item)
.. method:: GetItemIdentity(self, item)
Return a hashable object that represents the identity of the
item. By default this returns the position of the item in the
tree. You may want to override this to return the item label
(if you know that labels are unique and don't change), or return
something that represents the underlying domain object, e.g.
a database key.
.. method:: SetExpansionState(self, listOfExpandedItems)
SetExpansionState(listOfExpandedItems). Expands all tree items
whose identity, as determined by GetItemIdentity(item), is present
in the list and collapses all other tree items.
.. method:: SetExpansionStateOfChildren(self, listOfExpandedItems, item)
.. method:: SetExpansionStateOfItem(self, listOfExpandedItems, item)
.. attribute:: ExpansionState
GetExpansionState() -> list of expanded items. Expanded items
are coded as determined by the result of GetItemIdentity(item).
|