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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- 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 to False.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- class viser.GuiButtonGroupHandle[source]¶
Handle for a button group input in our visualizer.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- 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 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].
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- class viser.GuiFolderHandle[source]¶
Use as a context to place GUI elements into a folder.
- class viser.GuiPlotlyHandle[source]¶
Handle for updating and removing Plotly figures.
- property figure: go.Figure¶
Current content of this markdown element. Synchronized automatically when assigned.
- class viser.GuiUplotHandle[source]¶
Handle for updating and removing Uplot figures.
- data: Tuple[npt.NDArray[np.float64], ...]¶
Tuple of 1D numpy arrays containing chart data. First array is x-axis data, subsequent arrays are y-axis data for each series. All arrays must have matching lengths. Minimum 2 arrays required. Synchronized automatically when assigned.
- mode: Literal[1, 2] | None¶
1 = aligned (all series share axes), 2 = faceted (each series gets its own subplot panel). Defaults to 1. Synchronized automatically when assigned.
- Type:
Chart layout mode
- title: str | None¶
Chart title displayed at the top of the plot. Synchronized automatically when assigned.
- series: Tuple[uplot.Series, ...]¶
Series configuration objects defining visual appearance (colors, line styles, labels) and behavior for each data array. Must match data tuple length. Synchronized automatically when assigned.
- bands: Tuple[uplot.Band, ...] | None¶
High/low range visualizations between adjacent series indices. Useful for confidence intervals, error bounds, or min/max ranges. Synchronized automatically when assigned.
- scales: Dict[str, uplot.Scale] | None¶
Scale definitions controlling data-to-pixel mapping and axis ranges. Enables features like auto-ranging, manual bounds, time-based scaling, and logarithmic distributions. Multiple scales support dual-axis charts. Synchronized automatically when assigned.
- axes: Tuple[uplot.Axis, ...] | None¶
Axis configuration for positioning (top/right/bottom/left), tick formatting, grid styling, and spacing. Controls visual appearance of chart axes. Synchronized automatically when assigned.
- legend: uplot.Legend | None¶
Legend display options including positioning, styling, and custom value formatting for hover states. Synchronized automatically when assigned.
- cursor: uplot.Cursor | None¶
Interactive cursor behavior including hover detection, drag-to-zoom, and crosshair appearance. Controls user interaction with the chart. Synchronized automatically when assigned.
- focus: uplot.Focus | None¶
Visual highlighting when hovering over series. Controls alpha transparency of non-focused series to emphasize the active one. Synchronized automatically when assigned.
- class viser.GuiTabGroupHandle[source]¶
Handle for a tab group. Call
add_tab()
to add a tab.
- class viser.GuiCheckboxHandle[source]¶
Handle for checkbox inputs.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- class viser.GuiMultiSliderHandle[source]¶
Handle for multi-slider inputs.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async 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 ¶
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
- min_range: float | None¶
Minimum allowed range between slider handles. 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async 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 ¶
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
- 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.
- class viser.GuiRgbaHandle[source]¶
Handle for RGBA color inputs.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- class viser.GuiRgbHandle[source]¶
Handle for RGB color inputs.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- class viser.GuiTextHandle[source]¶
Handle for text inputs.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async def), it will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- class viser.GuiVector2Handle[source]¶
Handle for 2D vector inputs.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async 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 ¶
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
- 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.
- class viser.GuiVector3Handle[source]¶
Handle for 3D vector inputs.
- 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 with def), it will be executed in a thread pool. - If func is an async function (defined with async 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 ¶
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
- 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.