Phoenix Logo

phoenix_title wx.RearrangeList

A listbox-like control allowing the user to rearrange the items and to enable or disable them.

This class allows to change the order of the items shown in it as well as to check or uncheck 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.

New in version 2.9.0.


class_hierarchy Class Hierarchy

Inheritance diagram for class RearrangeList:

method_summary Methods Summary

__init__ Default constructor.
CanMoveCurrentDown Return True if the currently selected item can be moved down.
CanMoveCurrentUp Return True if the currently selected item can be moved up.
Create Effectively creates the window for an object created using the default constructor.
GetCurrentOrder Return the current order of the items.
MoveCurrentDown Move the currently selected item one position below.
MoveCurrentUp Move the currently selected item one position above.

property_summary Properties Summary

CurrentOrder See GetCurrentOrder

api Class API



class 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.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__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.

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) –





CanMoveCurrentDown(self)

Return True if the currently selected item can be moved down.

Return type:bool

See also

CanMoveCurrentUp



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.


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



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.

Return type:list of integers


MoveCurrentDown(self)

Move the currently selected item one position below.

Return type:bool

See also

MoveCurrentUp



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 or False if this couldn’t be done.

See also

MoveCurrentDown


Properties



CurrentOrder

See GetCurrentOrder