Phoenix Logo

phoenix_title wx.RearrangeDialog

A dialog allowing the user to rearrange the specified items.

This dialog can be used to allow the user to modify the order of the items and to enable or disable them individually. For example:

items = ["meat", "fish", "fruits", "beer"]
order = [3, 0, 1, 2]

dlg = wx.RearrangeDialog(None,
                         "You can also uncheck the items you don't like "
                         "at all.",
                         "Sort the items in order of preference",
                         order, items)

if dlg.ShowModal() == wx.ID_OK:
    order = dlg.GetOrder()
    for n in order:
        if n >= 0:
            wx.LogMessage("Your most preferred item is \"%s\""%n)
            break

New in version 2.9.0.


class_hierarchy Class Hierarchy

Inheritance diagram for class RearrangeDialog:


method_summary Methods Summary

__init__ Default constructor.
AddExtraControls Customize the dialog by adding extra controls to it.
Create Effectively creates the dialog for an object created using the default constructor.
GetList Return the list control used by the dialog.
GetOrder Return the array describing the order of items after it was modified by the user.

property_summary Properties Summary

List See GetList
Order See GetOrder

api Class API



class wx.RearrangeDialog(Dialog)

Possible constructors:

RearrangeDialog()

RearrangeDialog(parent, message, title="", order=[], items=[],
                pos=DefaultPosition, name=RearrangeDialogNameStr)

A dialog allowing the user to rearrange the specified items.


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, message, title=””, order=[], items=[], pos=DefaultPosition, name=RearrangeDialogNameStr)

Constructor creating the dialog.

Please see Create for the parameters description.

Parameters:
  • parent (wx.Window) –
  • message (string) –
  • title (string) –
  • order (list of integers) –
  • items (list of strings) –
  • pos (wx.Point) –
  • name (string) –





AddExtraControls(self, win)

Customize the dialog by adding extra controls to it.

This function adds the given win to the dialog, putting it just below the part occupied by wx.RearrangeCtrl. It must be called after creating the dialog and you will typically need to process the events generated by the extra controls for them to do something useful.

For example:

class MyRearrangeDialog(wx.RearrangeDialog):

    def __init__(self, parent):

        wx.RearrangeDialog.__init__(self, parent)

        panel = wx.Panel(self)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(wx.StaticText(panel, wx.ID_ANY,
                                "Column width in pixels:"))
        sizer.Add(wx.TextCtrl(panel, wx.ID_ANY, ""))
        panel.SetSizer(sizer)
        self.AddExtraControls(panel)


        # ... code to update the text control with the currently selected
        # item width and to react to its changes omitted ...

See also the complete example of a custom rearrange dialog in the dialogs sample.

Parameters:win (wx.Window) – The window containing the extra controls. It must have this dialog as its parent.


Create(self, parent, message, title="", order=[], items=[], pos=DefaultPosition, name=RearrangeDialogNameStr)

Effectively creates the dialog for an object created using the default constructor.

Parameters:
  • parent (wx.Window) – The dialog parent, possibly None.
  • message (string) – The message shown inside the dialog itself, above the items list.
  • title (string) – The title of the dialog.
  • order (list of integers) – The initial order of the items in the convention used by wx.RearrangeList.
  • items (list of strings) – The items to show in the dialog.
  • pos (wx.Point) – Optional dialog position.
  • name (string) – Optional dialog name.
Return type:

bool

Returns:

True if the dialog was successfully created or False if creation failed.



GetList(self)

Return the list control used by the dialog.

Return type: wx.RearrangeList


GetOrder(self)

Return the array describing the order of items after it was modified by the user.

Please notice that the array will contain negative items if any items were unchecked. See wx.RearrangeList for more information about the convention used for this array.

Return type:list of integers

Properties



List

See GetList



Order

See GetOrder