omni.kit.window.popup_dialog¶
A variety 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.
MessageDialog
(width: int = 400, parent: Optional[omni.ui._ui.Widget] = None, message: str = '', title: Optional[str] = None, ok_handler: Optional[Callable[[omni.kit.window.popup_dialog.dialog.AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[omni.kit.window.popup_dialog.dialog.AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', disable_okay_button: bool = False, disable_cancel_button: bool = False)¶ This simplest of all popup dialogs displays a confirmation message before executing an action.
- Keyword Arguments
title (str) – Title of popup window. Default ‘message-dialog’.
message (str) – The displayed message. Default ‘’.
disable_cancel_button (bool) – If True, then don’t display ‘Cancel’ button. Default False.
-
destroy
()¶ Destructor
-
hide
()¶ Hides this dialog.
-
set_okay_clicked_fn
(ok_handler: Callable[[omni.kit.window.popup_dialog.dialog.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[omni.ui._ui.Widget] = None)¶ Shows this dialog, optionally offset from the parent widget, if any.
- Parameters
offset_x (int) – X offset. Default 0.
offset_y (int) – Y offset. Default 0.
-
class
omni.kit.window.popup_dialog.
InputDialog
(width: int = 400, parent: Optional[omni.ui._ui.Widget] = None, message: Optional[str] = None, title: Optional[str] = None, ok_handler: Optional[Callable[[omni.kit.window.popup_dialog.dialog.AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[omni.kit.window.popup_dialog.dialog.AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', input_cls: Optional[omni.ui._ui.AbstractField] = None, pre_label: Optional[str] = None, post_label: Optional[str] = None, default_value: Optional[str] = None)¶ A simple popup dialog with an input field and two buttons, OK and Cancel
- Keyword Arguments
title (str) – Title of popup window. Default ‘input-dialog’.
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
. Defaultomni.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
()¶ Destructor
-
get_value
() → Any¶ Returns field value.
- Returns
Any, e.g. one of [str, int, float, bool]
-
hide
()¶ Hides this dialog.
-
set_okay_clicked_fn
(ok_handler: Callable[[omni.kit.window.popup_dialog.dialog.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[omni.ui._ui.Widget] = None)¶ Shows this dialog, optionally offset from the parent widget, if any.
- Parameters
offset_x (int) – X offset. Default 0.
offset_y (int) – Y offset. Default 0.
-
class
omni.kit.window.popup_dialog.
FormDialog
(width: int = 400, parent: Optional[omni.ui._ui.Widget] = None, message: Optional[str] = None, title: Optional[str] = None, ok_handler: Optional[Callable[[omni.kit.window.popup_dialog.dialog.AbstractDialog], None]] = None, cancel_handler: Optional[Callable[[omni.kit.window.popup_dialog.dialog.AbstractDialog], None]] = None, ok_label: str = 'Ok', cancel_label: str = 'Cancel', field_defs: Optional[list] = None, input_width: int = 250)¶ 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 ‘input-dialog’.
field_defs ([
FormDialog.FieldDef
]) – List ofFieldDefs
. Default [].input_width (int) – Common width for all input fields. Default 250.
Note
FormDialog.FieldDef
: A namedtupe of type (name, label, type, default value), e.g.FormDialog.FieldDef(“name”, “Name: “,
omni.ui.StringField
, “Bob”).
-
FieldDef
¶ alias of
omni.kit.window.popup_dialog.form_dialog.FormDialogFieldDef
-
destroy
()¶ Destructor
-
get_field
(name: str) → omni.ui._ui.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.
-
hide
()¶ Hides this dialog.
-
namedtuple
(field_names, *, rename=False, defaults=None, module=None)¶ Returns a new subclass of tuple with named fields.
>>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22)
-
reset_values
()¶ Resets all values to their defaults.
-
set_okay_clicked_fn
(ok_handler: Callable[[omni.kit.window.popup_dialog.dialog.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[omni.ui._ui.Widget] = None)¶ Shows this dialog, optionally offset from the parent widget, if any.
- Parameters
offset_x (int) – X offset. Default 0.
offset_y (int) – Y offset. Default 0.