wx.RearrangeList¶
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.
Added in version 2.9.0.
Class Hierarchy¶
Methods Summary¶
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. |
Properties Summary¶
See |
Class API¶
- class wx.RearrangeList(CheckListBox)¶
Possible constructors:
RearrangeList() -> None RearrangeList(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, order=[], items=[], style=0, validator=DefaultValidator, name=RearrangeListNameStr) -> None
A listbox-like control allowing the user to rearrange the items and to enable or disable them.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor.
Create
must be called later to effectively create the control.- Return type:
None
__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.- Parameters:
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)
- Return type:
None
- CanMoveCurrentDown(self)¶
Return
True
if the currently selected item can be moved down.- Return type:
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.- Return type:
bool
- Returns:
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.- Parameters:
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.
- Return type:
bool
- static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶
- Parameters:
variant (WindowVariant)
- Return type:
- GetCurrentOrder(self)¶
Return the current order of the items.
The order may be different from the one passed to the constructor if
MoveCurrentUp
orMoveCurrentDown
were called.- Return type:
List[int]
- MoveCurrentDown(self)¶
Move the currently selected item one position below.
- Return type:
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.
- Return type:
bool
- Returns:
True
if the item was moved orFalse
if this couldn’t be done.
See also
Properties¶
- CurrentOrder¶
See
GetCurrentOrder