File: wx.lib.mixins.listctrl.ColumnSorterMixin.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 (165 lines) | stat: -rw-r--r-- 6,686 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
.. 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.listctrl

.. highlight:: python



.. _wx.lib.mixins.listctrl.ColumnSorterMixin:

==========================================================================================================================================
|phoenix_title|  **wx.lib.mixins.listctrl.ColumnSorterMixin**
==========================================================================================================================================

A mixin class that handles sorting of a wx.ListCtrl in REPORT mode when
the column header is clicked on.

There are a few requirments needed in order for this to work genericly:

  1. The combined class must have a GetListCtrl method that
     returns the wx.ListCtrl to be sorted, and the list control
     must exist at the time the wx.ColumnSorterMixin.__init__
     method is called because it uses GetListCtrl.

  2. Items in the list control must have a unique data value set
     with list.SetItemData.

  3. The combined class must have an attribute named itemDataMap
     that is a dictionary mapping the data values to a sequence of
     objects representing the values in each column.  These values
     are compared in the column sorter to determine sort order.

Interesting methods to override are GetColumnSorter,
GetSecondarySortValues, and GetSortImages.  See below for details.



|

|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>ColumnSorterMixin</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.listctrl.ColumnSorterMixin_inheritance.png" alt="Inheritance diagram of ColumnSorterMixin" 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.listctrl.ColumnSorterMixin.html" title="wx.lib.mixins.listctrl.ColumnSorterMixin" alt="" coords="5,5,272,35"/> </map> 
   </p>

|


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

================================================================================ ================================================================================
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.__init__`                       
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.GetColumnSorter`                Returns a callable object to be used for comparing column values when sorting.
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.GetColumnWidths`                Returns a list of column widths.  Can be used to help restore the current
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.GetSecondarySortValues`         Returns a tuple of 2 values to use for secondary sort values when the
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.GetSortImages`                  Returns a tuple of image list indexesthe indexes in the image list for an image to be put on the column
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.GetSortState`                   Return a tuple containing the index of the column that was last sorted
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.OnSortOrderChanged`             Callback called after sort order has changed (whenever user
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.SetColumnCount`                 
:meth:`~wx.lib.mixins.listctrl.ColumnSorterMixin.SortListItems`                  Sort the list on demand.  Can also be used to set the sort column and order.
================================================================================ ================================================================================


|


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


.. class:: ColumnSorterMixin

   A mixin class that handles sorting of a wx.ListCtrl in REPORT mode when
   the column header is clicked on.
   
   There are a few requirments needed in order for this to work genericly:
   
     1. The combined class must have a GetListCtrl method that
        returns the wx.ListCtrl to be sorted, and the list control
        must exist at the time the wx.ColumnSorterMixin.__init__
        method is called because it uses GetListCtrl.
   
     2. Items in the list control must have a unique data value set
        with list.SetItemData.
   
     3. The combined class must have an attribute named itemDataMap
        that is a dictionary mapping the data values to a sequence of
        objects representing the values in each column.  These values
        are compared in the column sorter to determine sort order.
   
   Interesting methods to override are GetColumnSorter,
   GetSecondarySortValues, and GetSortImages.  See below for details.

   .. method:: __init__(self, numColumns)


   .. method:: GetColumnSorter(self)

      Returns a callable object to be used for comparing column values when sorting.


   .. method:: GetColumnWidths(self)

      Returns a list of column widths.  Can be used to help restore the current
      view later.


   .. method:: GetSecondarySortValues(self, col, key1, key2)

      Returns a tuple of 2 values to use for secondary sort values when the
      items in the selected column match equal.  The default just returns the
      item data values.


   .. method:: GetSortImages(self)

      Returns a tuple of image list indexesthe indexes in the image list for an image to be put on the column
      header when sorting in descending order.


   .. method:: GetSortState(self)

      Return a tuple containing the index of the column that was last sorted
      and the sort direction of that column.
      Usage:
      col, ascending = self.GetSortState()
      # Make changes to list items... then resort
      self.SortListItems(col, ascending)


   .. method:: OnSortOrderChanged(self)

      Callback called after sort order has changed (whenever user
      clicked column header).


   .. method:: SetColumnCount(self, newNumColumns)


   .. method:: SortListItems(self, col=-1, ascending=1)

      Sort the list on demand.  Can also be used to set the sort column and order.