comet.dialog

This module provides helper functionality to create commonly used dialogs for querying user input.

See also

Class CDialog

Create custom dialogs dialogs for your scripts.

Methods

comet.dialog.create(dialogSpec='')

Create a new CDialog object which can then be further modified using the class functions.

The dialog can either be created using an existing dialog specification - which is a JSON string - or by not providing a specification, resulting in a new empty dialog.

Parameters

dialogSpec (str) –

The JSON specification.

  • Empty str: Empty dialog

Returns

The newly created dialog. This dialog is not shown yet!

Return type

CDialog

Raises

CometError – On internal error

Available

comet.dialog.askStr(title='', label='', text='', okay='', cancel='', multiLine=True, maxChars=- 1)

Open a dialog to enter text.

Parameters
  • title (str) – The dialog title.

  • label (str) – Hint for the text field.

  • text (str) – The initial text for the entry field.

  • okay (str) – Caption for the ‘Ok’ button. * Empty str: ‘Okay’

  • cancel (str) – Caption for the ‘Cancel’ button. * Empty str: ‘Cancel’

  • multiLine (bool) – Whether the dialog should have a text field for entering multi line text.

  • maxChars (int) –

    Impose a limit to the number of characters that can be entered. * <0: No limit.

    Warning

    Not implemented when parameter multiLine is True

Returns

Whether the user accepted the dialog, and the content of the text field.

Return type

tuple[bool, str]

Raises
Available

CScript

askstring

comet.dialog.selectFile(title='', askForNew=False, suggestion='')

Open a dialog to select an existing file or get the path for a new file.

Parameters
  • title (str) – The dialog title.

  • askForNew (bool) –

    • True: Ask for a filepath for a new file

    • False: Ask for an existing file

  • suggestion (str) –

    Full path for a suggested file.

    May contain tokens like $DESKTOP, etc…

Returns

  • User selected a path: The selected filepath

  • User cancelled: None

Return type

str | None

Raises
Available

CScript

file::select_file

comet.dialog.selectFolder(title='', suggestion='')

Open a dialog to select an existing folder.

Parameters
  • title (str) – The dialog title

  • suggestion (str) –

    Full path for a suggested folder.

    May contain tokens like $DESKTOP, etc…

Returns

  • User selected a path: The selected folder

  • User cancelled: None

Return type

str | None

Raises
Available

CScript

file::select_folder