Alert¶
Enables showing modal alerts.
- class Alert(title: str, subtitle: str, window_id: Optional[str] = None)¶
A modal alert.
- Parameters
title – The title, shown in bold at the top.
subtitle – The informative text, which may be more than one line long.
window_id – The window to attach the alert to. If None, it will be application modal.
See also
Example “One-Shot Alert”
- async async_run(connection: iterm2.connection.Connection) → int¶
Shows the modal alert.
- Return type
int- Parameters
connection (
Connection) – The connection to use.- Returns
The index of the selected button, plus 1000. If no buttons
- were defined
then a single button, “OK”, is automatically added.
- Throws
RPCExceptionif something goes wrong.
- property subtitle: str¶
Returns the subtitle string
- property title: str¶
Returns the title string
- class TextInputAlert(title: str, subtitle: str, placeholder: str, default_value: str, window_id: Optional[str] = None)¶
A modal alert with a text input accessory.
- Parameters
title – The title, shown in bold at the top.
subtitle – The informative text, which may be more than one line long.
placeholder – Grayed-out text to show in the text field when it is empty.
default_value – Default text to place in the text field.
window_id – Window ID to attach to, or None to make app-modal.
- async async_run(connection: iterm2.connection.Connection) → Optional[str]¶
Shows the modal alert.
- Parameters
connection (
Connection) – The connection to use.- Returns
The string entered, or None if the alert was canceled.
- Throws
RPCExceptionif something goes wrong.
- property default_value: str¶
Returns the default value.
- property placeholder: str¶
Returns the placeholder string
- property subtitle: str¶
Returns the subtitle string
- property title: str¶
Returns the title string
- property window_id: Optional[str]¶
Returns the window ID
- class PolyModalAlert(title: str, subtitle: str, window_id: Optional[str] = None)¶
A modal alert with various UI options
- Parameters
title – The title, shown in bold at the top.
subtitle – The informative text, which may be more than one line long.
window_id – The window to attach the alert to. If None, it will be application modal.”
- add_checkbox_item(item_text: str, item_default: int = 0)¶
Adds a single checkbox item to the end of the list of checkboxes.
- item_textstr
The label for the checkbox.
- item_defaultint, optional
The default value of the checkbox (0 for unchecked, 1 for checked). Default is 0.
- add_checkboxes(items: List[str], defaults: List[int])¶
Adds an array of checkbox items to the end of the list of checkboxes. Parameters ———- items : List[str]
A list of labels for the checkboxes to add.
- defaultsList[int]
A list of default values (e.g., 0 or 1) indicating whether each checkbox is initially checked. Must have the same length as items.
- AssertionError
If items and defaults do not have the same length.
- add_combobox(items: List[str], default: Optional[str] = None)¶
Adds multiple items to the combobox list and sets the default value.
- itemsList[str]
A list of strings to add to the combobox.
- defaultstr, optional
The default value for the combobox. If empty, no default is set.
- AssertionError
If `default ` is not present in items.
- add_combobox_item(item_text: str, is_default: bool = False)¶
Adds a single item to the combobox list and optionally sets it as default.
- item_textstr
The text of the combobox item to add.
- is_defaultbool, optional
If True, this item becomes the default selection.
- add_text_field(placeholder: str, default: str)¶
Adds a text field to the alert.
- placeholderstr
The placeholder text to show in the text field.
- defaultstr
The default text value of the text field.
- async async_run(connection: iterm2.connection.Connection) → iterm2.alert.PolyModalResult¶
Shows the poly modal alert.
- Return type
PolyModalResult- Parameters
connection (
Connection) – The connection to use.- Returns
A PolyModalResult object containing values corresponding to
- the UI elements that were added
the label of clicked button
text entered into the field input
selected combobox text (’’ if combobox was present but nothing
selected) - array of checked checkbox labels.
- If no buttons were defined
- then a single button, “OK”, is automatically added
and “button” will be absent from PolyModalResult.
- Throws
RPCExceptionif something goes wrong.
- property checkbox_defaults: List[int]¶
Returns a list of whether checkboxes are checked by default
- property checkboxes: List[str]¶
Returns a list of checkbox strings
- property combobox_default: str¶
Returns the combox item that is initially chosen.
- property combobox_items: List[str]¶
Returns the list of strings that will populate the combobox.
- property subtitle: str¶
Returns the subtitle string
- property text_field: List[str]¶
Returns the text field list [placeholder, default]
- property title: str¶
Returns the title string
