comet.CDialog¶
- class comet.CDialog¶
This section describes all functions for the CDialog class.
For creating a dialog you need a dialog specification, which is a JSON string.
CDialog manages the dialog specification internally through the class functions, so there is no need for manual creating and editing.
To create a CDialog instance from either an existing specification string, or an empty dialog, use dialog.create()
.
Each control widget (checkbox, textfield, etc…) may appear multiple times in the specification, but must have a unique ID (string) within it’s own type. Afterwards, the dialog specification is used to build the dialog when show()
is called.
After the dialog has closed or an dialog event has been caught in a callback function, control results can be fetched using the get.. functions (getCheckBoxValue()
, …)
IDs with the prefix ‘%!’’ are reserved for internal use and must not be used for elements.
Warning
For technical reasons all get functions (e.g. getCheckBoxValue()
) will return values for the last opened dialog, which is not necessarily the calling CDialog object.
See also
Methods¶
- CDialog.setTitle(title)¶
Set the title of this dialog which is shown at the top of the dialog window.
The default is an empty title.
- Parameters
title (str) – The dialog title
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Returns
None
- Available
- CScript
- CDialog.setSize(width, height)¶
Set the initial size of this dialog.
The default is 500x300 pixels.
- Parameters
- Raises
TypeError – When parameter types are invalid
ValueError – When parameters width or height are < 1
CometError – On internal error
- Returns
None
- Available
- CScript
- CDialog.addLabel(ID, label, x, y, width, height, enabled=True, visible=True)¶
Insert a simple text label.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.addCheckBox(ID, label, checked, x, y, width, height, enabled=True, visible=True)¶
Insert a checkbox text label.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.addIntField(ID, value, x, y, width, height, enabled=True, visible=True)¶
Insert an int field.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.addFloatField(ID, value, x, y, width, height, enabled=True, visible=True)¶
Insert a float field.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.addTextField(ID, value, x, y, width, height, enabled=True, visible=True)¶
Insert a text field.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.addMultilineTextField(ID, value, x, y, width, height, enabled=True, visible=True)¶
Insert a multiline text field.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.addMultilineTextInfo(ID, value, x, y, width, height, enabled=True, visible=True)¶
Insert a multiline text label.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.addDropDown(ID, values, index, x, y, width, height, enabled=True, visible=True)¶
Insert a dropdown.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.addDefaultButtons(cancelEnabled=True, cancelVisible=True, okEnabled=True, okVisible=True, cancelLabel='', okLabel='', defaultButton=0)¶
Insert standard dialog buttons (‘Okay’ and ‘Cancel’). Buttons are positioned automatically according to the system UI recommondations. The IDs of these buttons are defined as follows:
Ok button: ‘kOk’
Cancel button: ‘kCancel’
- Parameters
cancelEnabled (bool) – State of the Cancel button
cancelVisible (bool) – Visibility of the Cancel button
okEnabled (bool) – State of the Ok button
okVisible (bool) – Visibility of the Ok button
cancelLabel (str) –
Label of the Cancel button. The label is automatically translated.
Empty str : ‘Cancel’
okLabel (str) –
Label of the Okay button. The label is automatically translated.
Empty str : ‘Okay’
defaultButton (int) –
Which button gets the default (Enter key)?
0: Okay button is default.
1: Cancel button is default.
- Returns
None
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter defaultButton has invalid value
CometError – On internal error
- Available
- CScript
- CDialog.show()¶
Show the dialog in modal fashion. After the dialog has been closed the user inputs can be fetched.
- Returns
None
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CDialog.getConfirmingButton()¶
Get the ID of the button which closed the dialog.
- Returns
The closing button ID.
’kOk’ : Okay-Button or return key
’kCancel’ : Cancel-Button or Command-Period (Mac only)
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.getCheckBoxValue(ID)¶
Get the result value of a checkbox.
- Parameters
ID (str) – ID of the element
- Returns
Whether the checkbox was checked
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.getTextFieldValue(ID)¶
Get the result value of a text field.
- Parameters
ID (str) – ID of the element
- Returns
The text value
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.getMultiLineTextFieldValue(ID)¶
Get the result value of a multiline text field.
- Parameters
ID (str) – ID of the element
- Returns
The text value
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.getFloatFieldValue(ID)¶
Get the result value of a float field.
- Parameters
ID (str) – ID of the element
- Returns
The value
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.getIntFieldValue(ID)¶
Get the result value of an int field.
- Parameters
ID (str) – ID of the element
- Returns
The value
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CDialog.getDropDownValue(ID)¶
Get the result value of a dropdown.
- Parameters
ID (str) – ID of the element
- Returns
The value as a tuple (index, value)
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript