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)
- parent
- The Qt parent widget.
- title
- Dialog's title.
- icon
- Dialog's icon.
- width/height
- Dialog's size.
- xmlrpc_clt
- The PyDADL XML-RPC handler. If you are inside a PyDADL application you could pass the Rpc variable here.
- modal
- If set to True the dialog is shown is modal mode.
- buttons
- Buttons to display : 0=None, 1=Ok, 2=Cancel, 4=Apply. Used only by Dialog class.
- flags
- Qt window flags.
- debug
- If set to True the dialog is shown in debug mode, it will display every change in the widgets.
- tr
- The PyDADL string translator. If you are inside a PyDADL application you could pass the Tr variable here.
- pixmaps
- 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.
- delWidget(name)
- 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.
- registerCallback(callback_func)
- 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.
- setTitle(title)
- Set the dialog's title to title.
- setValues(values)
- Set the widgets values to values. values must be a dict with keys corresponding to the widgets names.
- show(maximized=False)
- Show the dialog. if maximized is set to True, the dialog is shown maximized.
- setApplyable(applyable=True)
- 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).
- apply(close=True)
- 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.
- toggleWaitCursor(state=None)
- 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_(r=0)
- Close the dialog and set the result code to r.
- msgBox(data)
- 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, ...".
| Note |
---|
The BaseDialog class is not intended to be initialized directly, use Dialog or Wizard instead.
|
The Dialog class defines the following functions :
- setOkText(text)
- Set the text of the Ok button to text.
- setCancelText(text)
- Set the text of the Cancel button to text.
- setApplyText(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.
- setPreviousText(text)
- Set the text of the Previous button to text.
- setNextText(text)
- Set the text of the Next button to text.
- setTerminateText(text)
- Set the text of the Terminate button to text.
- setCancelText(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.