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”, click_okay_handler=on_okay, click_cancel_handler=on_cancel,
)
-
class
omni.kit.window.popup_dialog.
MessageDialog
(**kwargs)¶ Bases:
omni.kit.window.popup_dialog.dialog.PopupDialog
This simplest of all popup dialogs displays a confirmation message before executing an action.
- Keyword Arguments
Inherited args from the base class.
- Keyword Arguments
width (int) – Window width. Default 400.
parent (
omni.ui.Widget
) – If specified, popup position is relative to this widget. Default None.message (str) – Headline message to display. Default None.
click_okay_handler (func) – Function to invoke when Ok button clicked. Function signature: void okay_handler(dialog:
PopupDialog
)click_cancel_handler (func) – Function to invoke when Cancel button clicked. Function signature: void cancel_handler(dialog:
PopupDialog
)okay_label (str) – Alternative text to display on ‘Accept’ button. Default ‘Ok’.
cancel_label (str) – Alternative text to display on ‘Cancel’ button. Default ‘Cancel’.
-
destroy
()¶ Destructor
-
hide
()¶ Hides this dialog.
-
set_okay_clicked_fn
(click_okay_handler: Callable)¶ Sets function to invoke when Okay button is clicked.
- Parameters
click_okay_handler (func) – Callback with signature: void okay_handler(dialog:
PopupDialog
)
-
class
omni.kit.window.popup_dialog.
InputDialog
(**kwargs)¶ Bases:
omni.kit.window.popup_dialog.dialog.PopupDialog
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’.
input_type (
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.
Inherited args from the base class.
- Keyword Arguments
width (int) – Window width. Default 400.
parent (
omni.ui.Widget
) – If specified, popup position is relative to this widget. Default None.message (str) – Headline message to display. Default None.
click_okay_handler (func) – Function to invoke when Ok button clicked. Function signature: void okay_handler(dialog:
PopupDialog
)click_cancel_handler (func) – Function to invoke when Cancel button clicked. Function signature: void cancel_handler(dialog:
PopupDialog
)okay_label (str) – Alternative text to display on ‘Accept’ button. Default ‘Ok’.
cancel_label (str) – Alternative text to display on ‘Cancel’ button. Default ‘Cancel’.
-
destroy
()¶ Destructor
-
get_value
() → Union[str, int, float]¶ Returns value of input field.
- Returns
Union[str, int, float, bool]
-
hide
()¶ Hides this dialog.
-
set_okay_clicked_fn
(click_okay_handler: Callable)¶ Sets function to invoke when Okay button is clicked.
- Parameters
click_okay_handler (func) – Callback with signature: void okay_handler(dialog:
PopupDialog
)
-
class
omni.kit.window.popup_dialog.
FormDialog
(**kwargs)¶ Bases:
omni.kit.window.popup_dialog.dialog.PopupDialog
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’.
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”).
Inherited args from the base class.
- Keyword Arguments
width (int) – Window width. Default 400.
parent (
omni.ui.Widget
) – If specified, popup position is relative to this widget. Default None.message (str) – Headline message to display. Default None.
click_okay_handler (func) – Function to invoke when Ok button clicked. Function signature: void okay_handler(dialog:
PopupDialog
)click_cancel_handler (func) – Function to invoke when Cancel button clicked. Function signature: void cancel_handler(dialog:
PopupDialog
)okay_label (str) – Alternative text to display on ‘Accept’ button. Default ‘Ok’.
cancel_label (str) – Alternative text to display on ‘Cancel’ button. Default ‘Cancel’.
-
FieldDef
¶ alias of
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
-
get_value
(name: str) → Union[str, int, float]¶ 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, *, verbose=False, rename=False, 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
(click_okay_handler: Callable)¶ Sets function to invoke when Okay button is clicked.
- Parameters
click_okay_handler (func) – Callback with signature: void okay_handler(dialog:
PopupDialog
)