omni.kit.window.popup_dialog

Simple Popup Dialogs with Input Fields

A set of simple popup dialogs with optional input fields and two buttons, OK and Cancel.

Example:

dialog = InputDialog(
    width=450,
    pre_label="prefix",
    post_label="postfix",
    ok_handler=on_okay,
    cancel_handler=on_cancel,
)
class omni.kit.window.popup_dialog.FormDialog(width: int = 400, parent: Optional[Widget] = None, message: Optional[str] = None, title: Optional[str] = None, ok_handler: Optional[Callable[[AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', field_defs: Optional[List[FormDialogFieldDef]] = None, input_width: int = 250)

Bases: PopupDialog

A simple popup dialog with a set of input fields and two buttons, OK and Cancel

Keyword Arguments
  • title (str) – Title of popup window. Default None.

  • message (str) – Message string.

  • field_defs ([FormDialog.FieldDef]) – List of FieldDefs. Default [].

  • input_width (int) – OBSOLETE.

Note

FormDialog.FieldDef:

A namedtuple of (name, label, type, default value) for describing the input field, e.g. FormDialog.FieldDef(“name”, “Name: “, omni.ui.StringField, “Bob”).

FieldDef

alias of FormDialogFieldDef

destroy()

Destructor

get_field(name: str) AbstractField

Returns widget corresponding to named field.

Parameters

name (str) – Name of the field.

Returns

omni.ui.AbstractField

get_value(name: str) Union[str, int, float, bool]

Returns value of the named field.

Parameters

name (str) – Name of the field.

Returns

Union[str, int, float, bool]

Note

Doesn’t currently return MultiFields correctly.

get_values() dict

Returns all values in a dict.

Parameters

name (str) – Name of the field.

Returns

dict

Note

Doesn’t currently return MultiFields correctly.

reset_values()

Resets all values to their defaults.

show(offset_x: int = 0, offset_y: int = 0, parent: Optional[Widget] = None)

Shows this dialog, optionally offset from the parent widget, if any.

Keyword Arguments
  • offset_x (int) – X offset. Default 0.

  • offset_y (int) – Y offset. Default 0.

  • parent (ui.Widget) – Offset from this parent widget. Default None.

class omni.kit.window.popup_dialog.FormWidget(message: Optional[str] = None, field_defs: List[FormDialogFieldDef] = [])

Bases: object

A simple form widget with a set of input fields. As opposed to the dialog class, the widget can be combined with other widget types in the same window.

Keyword Arguments
  • message (str) – Message string.

  • field_defs ([FormDialog.FieldDef]) – List of FieldDefs. Default [].

Note

FormDialog.FieldDef:

A namedtuple of (name, label, type, default value) for describing the input field, e.g. FormDialog.FieldDef(“name”, “Name: “, omni.ui.StringField, “Bob”).

destroy()
focus() None

Focus fields for the current widget.

get_field(name: str) AbstractField

Returns widget corresponding to named field.

Parameters

name (str) – Name of the field.

Returns

omni.ui.AbstractField

get_value(name: str) Union[str, int, float, bool]

Returns value of the named field.

Parameters

name (str) – Name of the field.

Returns

Union[str, int, float, bool]

Note

Doesn’t currently return MultiFields correctly.

get_values() dict

Returns all values in a dict.

Parameters

name (str) – Name of the field.

Returns

dict

Note

Doesn’t currently return MultiFields correctly.

reset_values()

Resets all values to their defaults.

class omni.kit.window.popup_dialog.InputDialog(width: int = 400, parent: Optional[Widget] = None, message: Optional[str] = None, title: Optional[str] = None, ok_handler: Optional[Callable[[AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', input_cls: Optional[AbstractField] = None, pre_label: Optional[str] = None, post_label: Optional[str] = None, default_value: Optional[str] = None, warning_message: Optional[str] = None)

Bases: PopupDialog

A simple popup dialog with an input field and two buttons, OK and Cancel

Keyword Arguments
  • title (str) – Title of popup window. Default None.

  • message (str) – Message to display.

  • input_cls (omni.ui.AbstractField) – Type of input field specified by class name, e.g. omni.ui.StringField, omni.ui.IntField, omni.ui.CheckBox. Default is omni.ui.StringField.

  • pre_label (str) – Text displayed before input field. Default None.

  • post_label (str) – Text displayed after input field. Default None.

  • default_value (str) – Default value of the input field.

  • warning_message (Optional[str]) – Warning message that will displayed in red with the warning glyph. Default None.

destroy()
get_value() Any

Returns field value.

Returns

Any, e.g. one of [str, int, float, bool]

class omni.kit.window.popup_dialog.InputWidget(message: Optional[str] = None, input_cls: Optional[AbstractField] = None, pre_label: Optional[str] = None, post_label: Optional[str] = None, default_value: Optional[Any] = None)

Bases: object

A simple widget with an input field. As opposed to the dialog class, the widget can be combined with other widget types in the same window.

Keyword Arguments
  • message (str) – Message to display.

  • input_cls (omni.ui.AbstractField) – Class of the input field, e.g. omni.ui.StringField, omni.ui.IntField, omni.ui.CheckBox. Default is omni.ui.StringField.

  • pre_label (str) – Text displayed before input field. Default None.

  • post_label (str) – Text displayed after input field. Default None.

  • default_value (str) – Default value of the input field.

destroy()
get_value() Any

Returns value of input field.

Returns

Any

class omni.kit.window.popup_dialog.MessageDialog(width: int = 400, parent: Optional[Widget] = None, message: str = '', title: Optional[str] = None, ok_handler: Optional[Callable[[AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', disable_okay_button: bool = False, disable_cancel_button: bool = False, warning_message: Optional[str] = None)

Bases: PopupDialog

This simplest of all popup dialogs displays a confirmation message before executing an action.

Keyword Arguments
  • title (str) – Title of popup window. Default None.

  • message (str) – The displayed message. Default ‘’.

  • disable_cancel_button (bool) – If True, then don’t display ‘Cancel’ button. Default False.

  • warning_message (Optional[str]) – Warning message that will displayed in red with the warning glyph. Default None.

destroy()
set_message(message: str)

Updates the message string.

Parameters

message (str) – The message string.

class omni.kit.window.popup_dialog.MessageWidget(message: str = '')

Bases: object

This widget displays a custom message. As opposed to the dialog class, the widget can be combined with other widget types in the same window.

Keyword Arguments

message (str) – The message string

destroy()
set_message(message: str)

Updates the message string.

Parameters

message (str) – The message string.

class omni.kit.window.popup_dialog.OptionsDialog(width: int = 400, parent: Optional[Widget] = None, message: Optional[str] = None, title: Optional[str] = None, ok_handler: Optional[Callable[[AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', field_defs: Optional[List[OptionsDialogFieldDef]] = None, value_changed_fn: Optional[Callable] = None, radio_group: bool = False)

Bases: PopupDialog

A simple checkbox dialog with a set options and two buttons, OK and Cancel

Keyword Arguments
  • title (str) – Title of popup window. Default None.

  • message (str) – Message string.

  • field_defs ([OptionsDialog.FieldDef]) – List of FieldDefs. Default [].

  • value_changed_fn (Callable) – This callback is triggered on any value change.

  • radio_group (bool) – If True, then only one option can be selected at a time.

Note

OptionsDialog.FieldDef:

A namedtuple of (name, label, default) for describing the options field, e.g. OptionsDialog.FieldDef(“option”, “Option”, True).

FieldDef

alias of OptionsDialogFieldDef

destroy()
get_choice() str

Returns name of chosen option.

Returns

str

get_value(name: str) bool

Returns value of the named field.

Parameters

name (str) – Name of the field.

Returns

bool

get_values() Dict

Returns all values in a dictionary.

Returns

Dict

class omni.kit.window.popup_dialog.OptionsMenu(width: int = 400, parent: Optional[Widget] = None, title: Optional[str] = None, ok_handler: Optional[Callable[[AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', field_defs: Optional[List[OptionsMenuFieldDef]] = None, value_changed_fn: Optional[Callable] = None)

Bases: PopupDialog

A simple checkbox menu with a set of options

Keyword Arguments
  • title (str) – Title of this menu. Default None.

  • field_defs ([OptionsMenu.FieldDef]) – List of FieldDefs. Default [].

  • value_changed_fn (Callable) – This callback is triggered on any value change.

Note

OptionsMenu.FieldDef:

A namedtuple of (name, label, glyph, default) for describing the options field, e.g. OptionsDialog.FieldDef(“option”, “Option”, None, True).

FieldDef

alias of OptionsMenuFieldDef

destroy()

Destructor

get_value(name: str) bool

Returns value of the named field.

Parameters

name (str) – Name of the field.

Returns

bool

get_values() dict

Returns all values in a dictionary.

Returns

dict

reset_values()

Resets all values to their defaults.

set_value(name: str, value: bool)

Sets the value of the named field.

Parameters
  • name (str) – Name of the field.

  • value (bool) – New value

class omni.kit.window.popup_dialog.OptionsMenuWidget(title: Optional[str] = None, field_defs: List[OptionsMenuFieldDef] = [], value_changed_fn: Optional[Callable] = None, build_ui: bool = True)

Bases: object

A simple checkbox widget with a set of options. As opposed to the menu class, the widget can be combined with other widget types in the same window.

Keyword Arguments
  • title (str) – Title of this menu. Default None.

  • field_defs ([OptionsDialog.FieldDef]) – List of FieldDefs. Default [].

  • value_changed_fn (Callable) – This callback is triggered on any value change.

  • build_ui (bool) – Build ui when created.

Note

OptionsMenu.FieldDef:

A namedtuple of (name, label, glyph, default) for describing the options field, e.g. OptionsDialog.FieldDef(“option”, “Option”, None, True).

build_ui()
destroy()
get_value(name: str) bool

Returns value of the named field.

Parameters

name (str) – Name of the field.

Returns

bool

get_values() dict

Returns all values in a dictionary.

Returns

dict

reset_values()

Resets all values to their defaults.

set_value(name: str, value: bool)

Sets the value of the named field.

Parameters
  • name (str) – Name of the field.

  • value (bool) – New value

class omni.kit.window.popup_dialog.OptionsWidget(message: Optional[str] = None, field_defs: List[OptionsDialogFieldDef] = [], value_changed_fn: Optional[Callable] = None, radio_group: bool = False)

Bases: object

A simple checkbox widget with a set options. As opposed to the dialog class, the widget can be combined with other widget types in the same window.

Keyword Arguments
  • message (str) – Message string.

  • field_defs ([OptionsDialog.FieldDef]) – List of FieldDefs. Default [].

  • value_changed_fn (Callable) – This callback is triggered on any value change.

  • radio_group (bool) – If True, then only one option can be selected at a time.

Note

OptionsDialog.FieldDef:

A namedtuple of (name, label, default) for describing the options field, e.g. OptionsDialog.FieldDef(“option”, “Option”, True).

destroy()
get_choice() str

Returns name of chosen option.

Returns

str

get_value(name: str) bool

Returns value of the named field.

Parameters

name (str) – Name of the field.

Returns

bool

get_values() dict

Returns all values in a dictionary.

Returns

dict

class omni.kit.window.popup_dialog.PopupDialog(width: int = 400, parent: Optional[Widget] = None, title: Optional[str] = None, ok_handler: Optional[Callable[[AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', hide_title_bar: bool = False, modal: bool = False, warning_message: Optional[str] = None)

Bases: AbstractDialog

Base class for a simple popup dialog with two primary buttons, OK and Cancel.

WINDOW_FLAGS = 67108874
destroy()
hide()

Hides this dialog.

property position_x
property position_y
set_cancel_clicked_fn(cancel_handler: Callable[[AbstractDialog], None])

Sets function to invoke when Cancel button is clicked.

Parameters

cancel_handler (Callable) – Callback with signature: void cancel_handler(dialog: PopupDialog)

set_okay_clicked_fn(ok_handler: Callable[[AbstractDialog], None])

Sets function to invoke when Okay button is clicked.

Parameters

ok_handler (Callable) – Callback with signature: void okay_handler(dialog: PopupDialog)

show(offset_x: int = 0, offset_y: int = 0, parent: Optional[Widget] = None, recreate_window: bool = False)

Shows this dialog, optionally offset from the parent widget, if any.

Keyword Arguments
  • offset_x (int) – X offset. Default 0.

  • offset_y (int) – Y offset. Default 0.

  • parent (ui.Widget) – Offset from this parent widget. Default None.

  • recreate_window (bool) – Recreate popup window. Default False.

property window