GUI Handles#
A handle is created for each GUI element that is added. Handles can be used to read and write state.
When a GUI element is added to a server (for example, via
viser.ViserServer.add_gui_text()
), state is synchronized between all
connected clients. When a GUI element is added to a client (for example, via
viser.ClientHandle.add_gui_text()
), state is local to a specific client.
- class viser.GuiInputHandle[source]#
Handle for a general GUI inputs in our visualizer.
Lets us get values, set values, and detect updates.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], None]) Callable[[GuiEvent[TGuiHandle]], None] [source]#
Attach a function to call when a GUI input is updated. Happens in a thread.
- __post_init__() None #
We need to register ourself after construction for callbacks to work.
- Return type:
None
- property disabled: bool#
Allow/disallow user interaction with the input. Synchronized automatically when assigned.
- property order: float#
Read-only order value, which dictates the position of the GUI element.
- remove() None #
Permanently remove this GUI element from the visualizer.
- Return type:
None
- property update_timestamp: float#
Read-only timestamp when this input was last updated.
- property value: T#
Value of the GUI input. Synchronized automatically when assigned.
- property visible: bool#
Temporarily show or hide this GUI element from the visualizer. Synchronized automatically when assigned.
- class viser.GuiButtonHandle[source]#
Handle for a button input in our visualizer.
Lets us detect clicks.
- on_click(func: Callable[[GuiEvent[TGuiHandle]], None]) Callable[[GuiEvent[TGuiHandle]], None] [source]#
Attach a function to call when a button is pressed. Happens in a thread.
- __post_init__() None #
We need to register ourself after construction for callbacks to work.
- Return type:
None
- property disabled: bool#
Allow/disallow user interaction with the input. Synchronized automatically when assigned.
- property order: float#
Read-only order value, which dictates the position of the GUI element.
- remove() None #
Permanently remove this GUI element from the visualizer.
- Return type:
None
- property update_timestamp: float#
Read-only timestamp when this input was last updated.
- property value: T#
Value of the GUI input. Synchronized automatically when assigned.
- property visible: bool#
Temporarily show or hide this GUI element from the visualizer. Synchronized automatically when assigned.
- class viser.GuiButtonGroupHandle[source]#
Handle for a button group input in our visualizer.
Lets us detect clicks.
- on_click(func: Callable[[GuiEvent[TGuiHandle]], None]) Callable[[GuiEvent[TGuiHandle]], None] [source]#
Attach a function to call when a button is pressed. Happens in a thread.
- property disabled: bool#
Button groups cannot be disabled.
- __post_init__() None #
We need to register ourself after construction for callbacks to work.
- Return type:
None
- property order: float#
Read-only order value, which dictates the position of the GUI element.
- remove() None #
Permanently remove this GUI element from the visualizer.
- Return type:
None
- property update_timestamp: float#
Read-only timestamp when this input was last updated.
- property value: T#
Value of the GUI input. Synchronized automatically when assigned.
- property visible: bool#
Temporarily show or hide this GUI element from the visualizer. Synchronized automatically when assigned.
- class viser.GuiDropdownHandle[source]#
Handle for a dropdown-style GUI input in our visualizer.
Lets us get values, set values, and detect updates.
- property options: Tuple[StringType, ...]#
Options for our dropdown. Synchronized automatically when assigned.
For projects that care about typing: the static type of
options
should be consistent with theStringType
associated with a handle. Literal types will be inferred where possible when handles are instantiated; for the most flexibility, we can declare handles asGuiDropdownHandle[str]
.
- __post_init__() None #
We need to register ourself after construction for callbacks to work.
- Return type:
None
- property disabled: bool#
Allow/disallow user interaction with the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], None]) Callable[[GuiEvent[TGuiHandle]], None] #
Attach a function to call when a GUI input is updated. Happens in a thread.
- property order: float#
Read-only order value, which dictates the position of the GUI element.
- remove() None #
Permanently remove this GUI element from the visualizer.
- Return type:
None
- property update_timestamp: float#
Read-only timestamp when this input was last updated.
- property value: T#
Value of the GUI input. Synchronized automatically when assigned.
- property visible: bool#
Temporarily show or hide this GUI element from the visualizer. Synchronized automatically when assigned.
- class viser.GuiFolderHandle[source]#
Use as a context to place GUI elements into a folder.
- property order: float#
Read-only order value, which dictates the position of the GUI element.
- class viser.GuiMarkdownHandle[source]#
Use to remove markdown.
- property content: str#
Current content of this markdown element. Synchronized automatically when assigned.
- property order: float#
Read-only order value, which dictates the position of the GUI element.
- property visible: bool#
Temporarily show or hide this GUI element from the visualizer. Synchronized automatically when assigned.
- class viser.GuiTabGroupHandle[source]#
GuiTabGroupHandle(_tab_group_id: ‘str’, _labels: ‘List[str]’, _icons_html: ‘List[Optional[str]]’, _tabs: ‘List[GuiTabHandle]’, _gui_api: ‘GuiApi’, _parent_container_id: ‘str’, _order: ‘float’)
- property order: float#
Read-only order value, which dictates the position of the GUI element.
- add_tab(label: str, icon: IconName | None = None) GuiTabHandle [source]#
Add a tab. Returns a handle we can use to add GUI elements to it.
- Parameters:
label (str) –
icon (IconName | None) –
- Return type: