GUI Handles#

class viser.GuiInputHandle[source]#

A handle is created for each GUI element that is added in viser. Handles can be used to read and write state.

When a GUI element is added via ViserServer.gui, state is synchronized between all connected clients. When a GUI element is added via ClientHandle.gui, state is local to a specific client.

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.

Parameters:
  • self (TGuiHandle) –

  • func (Callable[[GuiEvent[TGuiHandle]], None]) –

Return type:

Callable[[GuiEvent[TGuiHandle]], None]

__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.

Parameters:
  • self (TGuiHandle) –

  • func (Callable[[GuiEvent[TGuiHandle]], None]) –

Return type:

Callable[[GuiEvent[TGuiHandle]], None]

__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.

Parameters:
  • self (TGuiHandle) –

  • func (Callable[[GuiEvent[TGuiHandle]], None]) –

Return type:

Callable[[GuiEvent[TGuiHandle]], None]

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 the StringType associated with a handle. Literal types will be inferred where possible when handles are instantiated; for the most flexibility, we can declare handles as GuiDropdownHandle[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.

Parameters:
  • self (TGuiHandle) –

  • func (Callable[[GuiEvent[TGuiHandle]], None]) –

Return type:

Callable[[GuiEvent[TGuiHandle]], 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.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.

remove() None[source]#

Permanently remove this folder and all contained GUI elements from the visualizer.

Return type:

None

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.

__post_init__() None[source]#

We need to register ourself after construction for callbacks to work.

Return type:

None

remove() None[source]#

Permanently remove this markdown from the visualizer.

Return type:

None

class viser.GuiPlotlyHandle[source]#

Use to update or remove markdown elements.

property figure: go.Figure#

Current content of this markdown element. Synchronized automatically when assigned.

property aspect: float#

Aspect ratio of the plotly figure, in the control panel.

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.

__post_init__() None[source]#

We need to register ourself after construction for callbacks to work.

Return type:

None

remove() None[source]#

Permanently remove this figure from the visualizer.

Return type:

None

class viser.GuiTabGroupHandle[source]#

Handle for a tab group. Call add_tab() to add a tab.

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:

GuiTabHandle

remove() None[source]#

Remove this tab group and all contained GUI elements.

Return type:

None

class viser.GuiTabHandle[source]#

Use as a context to place GUI elements into a tab.

remove() None[source]#

Permanently remove this tab and all contained GUI elements from the visualizer.

Return type:

None