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 viaClientHandle.gui
, state is local to a specific client.- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] [source]¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None [source]¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- 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.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- class viser.GuiButtonHandle[source]¶
Handle for a button input in our visualizer.
- value: bool¶
Value of the button. Set to
True
when the button is pressed. Can be manually set back toFalse
.
- on_click(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] [source]¶
Attach a function to call when a button is pressed.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- 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.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- class viser.GuiButtonGroupHandle[source]¶
Handle for a button group input in our visualizer.
- value: str¶
Value of the input. Represents the currently selected button in the group.
- on_click(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] [source]¶
Attach a function to call when a button in the group is clicked.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- property disabled: bool¶
Button groups cannot be disabled.
- 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.
- options: Tuple[str, ...]¶
Tuple of buttons for the button group. Synchronized automatically when assigned.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- class viser.GuiDropdownHandle[source]¶
Handle for a dropdown-style GUI input in our visualizer.
- value: StringType¶
Value of the input. Represents the currently selected option in the dropdown.
- 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]
.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- class viser.GuiFolderHandle[source]¶
Use as a context to place GUI elements into a folder.
- remove() None [source]¶
Permanently remove this folder and all contained GUI elements from the visualizer.
- Return type:
None
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI folder. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI folder. Synchronized automatically when assigned.
- expand_by_default: bool¶
Whether the folder should be expanded by default. Synchronized automatically when assigned.
- class viser.GuiMarkdownHandle[source]¶
Handling for updating and removing markdown elements.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the markdown element. Synchronized automatically when assigned.
- property content: str¶
Current content of this markdown element. Synchronized automatically when assigned.
- class viser.GuiPlotlyHandle[source]¶
Handle for updating and removing Plotly figures.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- aspect: float¶
Aspect ratio of the plot. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the plot. Synchronized automatically when assigned.
- property figure: go.Figure¶
Current content of this markdown element. Synchronized automatically when assigned.
- class viser.GuiTabGroupHandle[source]¶
Handle for a tab group. Call
add_tab()
to add a tab.- 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:
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the tab group. Synchronized automatically when assigned.
- class viser.GuiCheckboxHandle[source]¶
Handle for checkbox inputs.
- value: bool¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- class viser.GuiMultiSliderHandle[source]¶
Handle for multi-slider inputs.
- value: tuple[IntOrFloat, ...]¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- min: float¶
Minimum value for the multi-slider. Synchronized automatically when assigned.
- max: float¶
Maximum value for the multi-slider. Synchronized automatically when assigned.
- step: float¶
Step size for the multi-slider. Synchronized automatically when assigned.
- min_range: float | None¶
Minimum allowed range between slider handles. Synchronized automatically when assigned.
- precision: int¶
Number of decimal places to display for the multi-slider values. Synchronized automatically when assigned.
- fixed_endpoints: bool¶
If True, the first and last handles cannot be moved. Synchronized automatically when assigned.
- class viser.GuiNumberHandle[source]¶
Handle for number inputs.
- value: IntOrFloat¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- precision: int¶
Number of decimal places to display for the number value. Synchronized automatically when assigned.
- step: float¶
Step size for incrementing/decrementing the number value. Synchronized automatically when assigned.
- min: float | None¶
Minimum allowed value for the number input. Synchronized automatically when assigned.
- max: float | None¶
Maximum allowed value for the number input. Synchronized automatically when assigned.
- class viser.GuiRgbaHandle[source]¶
Handle for RGBA color inputs.
- value: tuple[int, int, int, int]¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- class viser.GuiRgbHandle[source]¶
Handle for RGB color inputs.
- value: tuple[int, int, int]¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- class viser.GuiSliderHandle[source]¶
Handle for slider inputs.
- value: IntOrFloat¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- min: float¶
Minimum value for the slider. Synchronized automatically when assigned.
- max: float¶
Maximum value for the slider. Synchronized automatically when assigned.
- step: float¶
Step size for the slider. Synchronized automatically when assigned.
- precision: int¶
Number of decimal places to display for the slider value. Synchronized automatically when assigned.
- class viser.GuiTextHandle[source]¶
Handle for text inputs.
- value: str¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- class viser.GuiUploadButtonHandle[source]¶
Handle for an upload file button in our visualizer.
The
.value
attribute will be updated with the contents of uploaded files.- value: UploadedFile¶
Value of the input. Contains information about the uploaded file.
- on_upload(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] [source]¶
Attach a function to call when a file is uploaded.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- 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.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- class viser.UploadedFile[source]¶
Result of a file upload.
- name: str¶
Name of the file.
- content: bytes¶
Contents of the file.
- class viser.GuiVector2Handle[source]¶
Handle for 2D vector inputs.
- value: tuple[float, float]¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- min: Tuple[float, float] | None¶
Minimum allowed values for each component of the vector. Synchronized automatically when assigned.
- max: Tuple[float, float] | None¶
Maximum allowed values for each component of the vector. Synchronized automatically when assigned.
- step: float¶
Step size for incrementing/decrementing each component of the vector. Synchronized automatically when assigned.
- precision: int¶
Number of decimal places to display for each component of the vector. Synchronized automatically when assigned.
- class viser.GuiVector3Handle[source]¶
Handle for 3D vector inputs.
- value: tuple[float, float, float]¶
Value of the input. Synchronized automatically when assigned.
- on_update(func: Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine]) Callable[[GuiEvent[TGuiHandle]], NoneOrCoroutine] ¶
Attach a function to call when a GUI input is updated.
Note:
If
func
is a regular function (defined withdef
), it will be executed in a thread pool.If
func
is an async function (defined withasync def
), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- remove() None ¶
Permanently remove this GUI element from the visualizer.
- Return type:
None
- remove_update_callback(callback: Literal[‘all’] | Callable = 'all') None ¶
Remove update callbacks from the GUI input.
- Parameters:
callback (Literal[‘all’] | ~typing.Callable) – Either “all” to remove all callbacks, or a specific callback function to remove.
- Return type:
None
- property update_timestamp: float¶
Read-only timestamp when this input was last updated.
- order: float¶
Order value for arranging GUI elements. Synchronized automatically when assigned.
- label: str¶
Label text for the GUI element. Synchronized automatically when assigned.
- hint: str | None¶
Optional hint text for the GUI element. Synchronized automatically when assigned.
- visible: bool¶
Visibility state of the GUI element. Synchronized automatically when assigned.
- disabled: bool¶
Disabled state of the GUI element. Synchronized automatically when assigned.
- min: Tuple[float, float, float] | None¶
Minimum allowed values for each component of the vector. Synchronized automatically when assigned.
- max: Tuple[float, float, float] | None¶
Maximum allowed values for each component of the vector. Synchronized automatically when assigned.
- step: float¶
Step size for incrementing/decrementing each component of the vector. Synchronized automatically when assigned.
- precision: int¶
Number of decimal places to display for each component of the vector. Synchronized automatically when assigned.