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

dialog

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:
Returns:

None

Available:

InDesign® Illustrator®

CScript:

dialog::title

CDialog.setSize(width, height)

Set the initial size of this dialog.

The default is 500x300 pixels.

Parameters:
  • width (int) – New width in pixels

  • height (int) – New height in pixels

Raises:
Returns:

None

Available:

InDesign® Illustrator®

CScript:

dialog::size

CDialog.addLabel(ID, label, x, y, width, height, enabled=True, visible=True)

Insert a simple text label.

Parameters:
  • ID (str) – ID of the element

  • label (str) – The text to display

  • x (float) – The x position

  • y (float) – The x position

  • width (float) – The width

  • height (float) – The height

  • enabled (bool) – Enabled?

  • visible (bool) – Visible?

Returns:

None

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::label

CDialog.addCheckBox(ID, label, checked, x, y, width, height, enabled=True, visible=True)

Insert a checkbox text label.

Parameters:
  • ID (str) – ID of the element

  • label (str) – The text to display

  • checked (bool) – Initial check state

  • x (float) – The x position

  • y (float) – The x position

  • width (float) – The width

  • height (float) – The height

  • enabled (bool) – Enabled?

  • visible (bool) – Visible?

Returns:

None

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::checkbox

CDialog.addIntField(ID, value, x, y, width, height, enabled=True, visible=True)

Insert an int field.

Parameters:
  • ID (str) – ID of the element

  • value (int) – Initial value

  • x (float) – The x position

  • y (float) – The x position

  • width (float) – The width

  • height (float) – The height

  • enabled (bool) – Enabled?

  • visible (bool) – Visible?

Returns:

None

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::intfield

CDialog.addFloatField(ID, value, x, y, width, height, enabled=True, visible=True)

Insert a float field.

Parameters:
  • ID (str) – ID of the element

  • value (float) – Initial value

  • x (float) – The x position

  • y (float) – The x position

  • width (float) – The width

  • height (float) – The height

  • enabled (bool) – Enabled?

  • visible (bool) – Visible?

Returns:

None

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::floatfield

CDialog.addTextField(ID, value, x, y, width, height, enabled=True, visible=True)

Insert a text field.

Parameters:
  • ID (str) – ID of the element

  • value (str) – Initial value

  • x (float) – The x position

  • y (float) – The x position

  • width (float) – The width

  • height (float) – The height

  • enabled (bool) – Enabled?

  • visible (bool) – Visible?

Returns:

None

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::textfield

CDialog.addMultilineTextField(ID, value, x, y, width, height, enabled=True, visible=True)

Insert a multiline text field.

Parameters:
  • ID (str) – ID of the element

  • value (str) – Initial value

  • x (float) – The x position

  • y (float) – The x position

  • width (float) – The width

  • height (float) – The height

  • enabled (bool) – Enabled?

  • visible (bool) – Visible?

Returns:

None

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::multilinetextfield

CDialog.addMultilineTextInfo(ID, value, x, y, width, height, enabled=True, visible=True)

Insert a multiline text label.

Parameters:
  • ID (str) – ID of the element

  • value (str) – Value to display

  • x (float) – The x position

  • y (float) – The x position

  • width (float) – The width

  • height (float) – The height

  • enabled (bool) – Enabled?

  • visible (bool) – Visible?

Returns:

None

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::multilinetextinfo

CDialog.addDropDown(ID, values, index, x, y, width, height, enabled=True, visible=True)

Insert a dropdown.

Parameters:
  • ID (str) – ID of the element

  • values (list[str]) – Possible values to select

  • index (int) – The initially selected index

  • x (float) – The x position

  • y (float) – The x position

  • width (float) – The width

  • height (float) – The height

  • enabled (bool) – Enabled?

  • visible (bool) – Visible?

Returns:

None

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::dropdown

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:
Available:

InDesign® Illustrator®

CScript:

dialog::dialogbuttons

CDialog.show()

Show the dialog in modal fashion. After the dialog has been closed the user inputs can be fetched.

Returns:

None

Raises:
Available:

InDesign® Illustrator®

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:

str

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::rconfirmbutton

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:

bool

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::rcheckbox

CDialog.getTextFieldValue(ID)

Get the result value of a text field.

Parameters:

ID (str) – ID of the element

Returns:

The text value

Return type:

str

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::rtextfield

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:

str

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::rmultilinetextfield

CDialog.getFloatFieldValue(ID)

Get the result value of a float field.

Parameters:

ID (str) – ID of the element

Returns:

The value

Return type:

float

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::rfloatfield

CDialog.getIntFieldValue(ID)

Get the result value of an int field.

Parameters:

ID (str) – ID of the element

Returns:

The value

Return type:

int

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::rintfield

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:

tuple[int, str]

Raises:
Available:

InDesign® Illustrator®

CScript:

dialog::rdropdown

CDialog.getSpecification()

Get the JSON string specification which is managed internally by this instance.

Returns:

The dialog specification

Return type:

str

Available:

InDesign® Illustrator®

Special methods

CDialog.__repr__()

String representation.

Returns:

<CDialog> Title: Title

Specification: JSON Specification

Examples
<CDialog> Dialog Demo
Specification: ...

Return type:

str