4.4. Dialog/Wizard classes

The Dialog and Wizard classes are available from the module PyDADL.ui.dialogs.

When you create an XML file describing a dialog or a wizard, PyDADL client creates the corresponding object, this object is referenced by the variable d. It is also possible to create you own dialogs by initiating Dialog or Wizard class instance :

Dialog/Wizard(parent=None, title=None, icon=None, width=None, height=None, xmlrpc_clt=None, modal=False, buttons=None, flags=None, debug=False, tr=None, pixmaps=None)

The Qt parent widget.
Dialog's title.
Dialog's icon.
Dialog's size.
The PyDADL XML-RPC handler. If you are inside a PyDADL application you could pass the Rpc variable here.
If set to True the dialog is shown is modal mode.
Buttons to display : 0=None, 1=Ok, 2=Cancel, 4=Apply. Used only by Dialog class.
Qt window flags.
If set to True the dialog is shown in debug mode, it will display every change in the widgets.
The PyDADL string translator. If you are inside a PyDADL application you could pass the Tr variable here.
The PyDADL pixmaps handler. If you are inside a PyDADL application you could pass the Xpm variable here.

Dialog and Wizard classes derive from the BaseDialog class (that inherits QDialog Qt class) which defines the following functions :

addWidget(type, row=None, col=None, name=None, data=None, parent=None)
Create a PyDADL widget of type type named name within row and col and with the given parent. data is the widget's attributes, it can be a dict in the form {'attribute1':'value1', 'attribute2':'value2', ...} or a string in the form "#attribute1=value1#attribute2=value2". This function returns the PyDADL widget object.
Remove the widget named name.
addSpace(row=None, col=None, parent=None, width=-1, height=-1, h_layout='exp', v_layout='exp')
Add a blank space within row and col with the given parent. The space size is specified by width and height. The resize policy is specified with h_layout and v_layout, See Section 4.5, “Base widget class” for possible layout policies.
Register a callback function. It is possible to register more than one callback function, they will be called in the order of registration. The callback function must take one argument that will be a dict holding widgets values.
Set the dialog's title to title.
Set the widgets values to values. values must be a dict with keys corresponding to the widgets names.
Show the dialog. if maximized is set to True, the dialog is shown maximized.
Set the dialog applyable state to applyable. If set to True, The dialog can be validated and the callback function is called when the user clicks on "Ok" or "Apply" button ("Terminate" button for wizards).
Programmatically apply the dialog. The apply really occurs only when the dialog is in an applyable state. close determines if the dialog should be closed.
Toggle the wait cursor to state. If set to True, the wait cursor is shown. If set to False, the normal cursor is restored. If set to None the state is toggled.
Close the dialog and set the result code to r.
Display a message box. data can be a simple text that will be displayed or it can be in the form : "#msg= #title= #icon=question|info|warn|error] #buttons=Bt1, Bt2, ...".

The BaseDialog class is not intended to be initialized directly, use Dialog or Wizard instead.

The Dialog class defines the following functions :

Set the text of the Ok button to text.
Set the text of the Cancel button to text.
Set the text of the Apply button to text.

The Wizard class defines the following functions :

addPage(name, enabled=True)
Add a wizard page named name with the enabled state set to enabled.
setPageEnabled(name, enabled)
Change the page name state to enabled.
Set the text of the Previous button to text.
Set the text of the Next button to text.
Set the text of the Terminate button to text.
Set the text of the Cancel button to text.

The widget objects that a dialog holds are available via the dialog object : dialog_object.widget_name. Ex: d.my_widget_1.