A listbox-like control allowing the user to rearrange the items and to enable or disable them.
This class allows changing the order of the items shown in it as well as checking or unchecking them individually. The data structure used to allow this is the order array which contains the items indices indexed by their position with an added twist that the unchecked items are represented by the bitwise complement of the corresponding index (for any architecture using two’s complement for negative numbers representation (i.e. just about any at all) this means that a checked item N is represented by -N-1
in unchecked state). In practice this means that you must apply the C bitwise complement operator when constructing the order array, e.g.
order = [0] # checked item #0
So, for example, the array order [1
-3 0]
used in conjunction with the items array [“first”, “second”, “third”] means that the items order is “second”, “third”, “first” and the “third” item is unchecked while the other two are checked.
This convention is used both for the order argument of the control constructor or Create
and for the array returned from GetCurrentOrder
.
Usually this control will be used together with other controls allowing to move the items around in it interactively. The simplest possible solution is to use wx.RearrangeCtrl which combines it with two standard buttons to move the current item up or down.
Note that while most of the methods for items manipulation such as Append
, Insert
or Delete
, inherited from wx.ItemContainer work as expected for this class, Set
somewhat unexpectedly resets the order of the items as it clears the control first, also clearing the order as a side effect, before adding the new items.
New in version 2.9.0.
Default constructor. |
|
Return |
|
Return |
|
Effectively creates the window for an object created using the default constructor. |
|
Return the current order of the items. |
|
Move the currently selected item one position below. |
|
Move the currently selected item one position above. |
See |
wx.
RearrangeList
(CheckListBox)¶Possible constructors:
RearrangeList()
RearrangeList(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize,
order=[], items=[], style=0, validator=DefaultValidator,
name=RearrangeListNameStr)
A listbox-like control allowing the user to rearrange the items and to enable or disable them.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
Create
must be called later to effectively create the control.
__init__ (self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, order=[], items=[], style=0, validator=DefaultValidator, name=RearrangeListNameStr)
Constructor really creating the control.
Please see Create
for the parameters description.
parent (wx.Window) –
id (wx.WindowID) –
pos (wx.Point) –
size (wx.Size) –
order (list of integers) –
items (list of strings) –
style (long) –
validator (wx.Validator) –
name (string) –
CanMoveCurrentDown
(self)¶Return True
if the currently selected item can be moved down.
bool
See also
CanMoveCurrentUp
(self)¶Return True
if the currently selected item can be moved up.
This function is useful for EVT_UPDATE_UI
handler for the standard “Up” button often used together with this control and wx.RearrangeCtrl uses it in this way.
bool
True
if the currently selected item can be moved up in the listbox, False
if there is no selection or the current item is the first one.
See also
Create
(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, order=[], items=[], style=0, validator=DefaultValidator, name=RearrangeListNameStr)¶Effectively creates the window for an object created using the default constructor.
This function is very similar to wx.CheckListBox.Create
except that it has an additional parameter specifying the initial order of the items. Please see the class documentation for the explanation of the conventions used by the order argument.
parent (wx.Window) – The parent window, must be not None
.
id (wx.WindowID) – The window identifier.
pos (wx.Point) – The initial window position.
size (wx.Size) – The initial window size.
order (list of integers) – Array specifying the initial order of the items in items array.
items (list of strings) – The items to display in the list.
style (long) – The control style, there are no special styles for this class but the base class styles can be used here.
validator (wx.Validator) – Optional window validator.
name (string) – Optional window name.
bool
GetClassDefaultAttributes
(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
GetCurrentOrder
(self)¶Return the current order of the items.
The order may be different from the one passed to the constructor if MoveCurrentUp
or MoveCurrentDown
were called.
list of integers
MoveCurrentDown
(self)¶Move the currently selected item one position below.
bool
See also
MoveCurrentUp
(self)¶Move the currently selected item one position above.
This method is useful to implement the standard “Up” button behaviour and wx.RearrangeCtrl uses it for this.
bool
True
if the item was moved or False
if this couldn’t be done.
See also
CurrentOrder
¶See GetCurrentOrder