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.
Default constructor. |
|
Customize the dialog by adding extra controls to it. |
|
Effectively creates the dialog for an object created using the default constructor. |
|
Return the list control used by the dialog. |
|
Return the array describing the order of items after it was modified by the user. |
See |
|
See |
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.
__init__
(self, *args, **kw)¶__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.
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.
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.
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.
bool
True
if the dialog was successfully created or False
if creation failed.
GetClassDefaultAttributes
(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
GetList
(self)¶Return the list control used by the dialog.
See also
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.
list of integers