Prompt#

class omni.kit.widget.prompt.Prompt(
title,
text,
ok_button_text='OK',
cancel_button_text=None,
middle_button_text=None,
middle_2_button_text=None,
ok_button_fn=None,
cancel_button_fn=None,
middle_button_fn=None,
middle_2_button_fn=None,
modal=False,
on_closed_fn=None,
shortcut_keys=True,
no_title_bar=False,
width=None,
height=None,
callback_addons: List = [],
)#

Bases: object

Pop up a prompt window that asks the user a simple question with up to four buttons for answers.

Callbacks are executed for each button press, as well as when the window is closed manually.

Methods

__init__(title, text[, ok_button_text, ...])

Initialize the callbacks and window information

destroy()

Destructor.

hide()

Make the prompt window invisible

is_visible()

Returns True if the prompt is currently visible.

set_cancel_fn(on_cancel_button_clicked)

Define a new callback for when the third (cancel) button is clicked

set_confirm_fn(on_ok_button_clicked)

Define a new callback for when the first (okay) button is clicked

set_middle_2_button_fn(...)

Define a new callback for when the second (middle) button is clicked

set_middle_button_fn(on_middle_button_clicked)

Define a new callback for when the second (middle) button is clicked

set_on_closed_fn(on_on_closed)

Define a new callback for when the window is closed without pressing a button

set_text(text)

Set a new question label

show()

Make the prompt window visible

Attributes

visible

Get the prompt's visible stat.

__init__(
title,
text,
ok_button_text='OK',
cancel_button_text=None,
middle_button_text=None,
middle_2_button_text=None,
ok_button_fn=None,
cancel_button_fn=None,
middle_button_fn=None,
middle_2_button_fn=None,
modal=False,
on_closed_fn=None,
shortcut_keys=True,
no_title_bar=False,
width=None,
height=None,
callback_addons: List = [],
)#

Initialize the callbacks and window information

Parameters:
  • title (str) – Text appearing in the titlebar of the window.

  • text (str) – Text of the question being posed to the user.

  • ok_button_text (str) – Text for the first button.

  • cancel_button_text (str) – Text for the last button.

  • middle_button_text (str) – Text for the middle button.

  • middle_button_2_text (str) – Text for the second middle button.

  • ok_button_fn (Callable[[], None]) – Function executed when the first button is pressed.The function signature is: void on_button_clicked_fn(). Defaults to None.

  • cancel_button_fn (Callable[[], None]) – void on_button_clicked_fn(). Defaults to None.

  • middle_button_fn (Callable[[], None]) – void on_button_clicked_fn(). Defaults to None.

  • middle_2_button_fn (Callable[[], None]) – void on_button_clicked_fn(). Defaults to None.

  • modal (bool) – True if the window is modal, shutting down other UI until an answer is received

  • on_closed_fn (Callable[[], None]) – void on_button_clicked_fn(). Defaults to None.

  • shortcut_keys (bool) – If it can be confirmed or hidden with shortcut keys like Enter or ESC. Defaults to True.

  • no_title_bar (bool) – If it needs to show title bar. Defaults to True.

  • width (int) – The specified width. By default, it will use the computed width.

  • height (int) – The specified height. By default, it will use the computed height.

  • callback_addons (List) – Addon widgets which is appended in the prompt window. By default, it is empty.

destroy()#

Destructor.

hide()#

Make the prompt window invisible

is_visible() bool#

Returns True if the prompt is currently visible.

Returns:

bool

set_cancel_fn(on_cancel_button_clicked)#

Define a new callback for when the third (cancel) button is clicked

set_confirm_fn(on_ok_button_clicked)#

Define a new callback for when the first (okay) button is clicked

set_middle_2_button_fn(on_middle_2_button_clicked)#

Define a new callback for when the second (middle) button is clicked

set_middle_button_fn(on_middle_button_clicked)#

Define a new callback for when the second (middle) button is clicked

set_on_closed_fn(on_on_closed)#

Define a new callback for when the window is closed without pressing a button

set_text(text)#

Set a new question label

show()#

Make the prompt window visible

property visible#

Get the prompt’s visible stat.

Returns:

True is prompt is visible else False.

Return type:

bool