Add gui.add_panel() for floating side-by-side control panels#711
Open
ArthurAllshire wants to merge 4 commits into
Open
Add gui.add_panel() for floating side-by-side control panels#711ArthurAllshire wants to merge 4 commits into
ArthurAllshire wants to merge 4 commits into
Conversation
Adds viser.GuiApi.add_panel(), which opens a draggable, resizable floating window as a sibling of the main control panel. Useful when the default single-panel layout gets too tall or too narrow — panels can be placed side-by-side and sized independently. Features: - Drag title bar to move, right edge to resize. - Position and width persist to localStorage per-panel uuid. - initial_position=(x, y); negative values anchor to right/bottom edge. - layout="row" renders children side-by-side with equal flex share. Example: examples/02_gui/11_panels.py.
test_docs_coverage.py was failing because GuiPanelHandle wasn't listed in docs/source/api/handles/gui_handles.rst. Fixed by re-running `python docs/generate_handle_docs.py`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Screen.Recording.2026-05-04.at.8.10.40.PM_compressed.mp4
Adds
viser.GuiApi.add_panel(), which opens a draggable, resizable floating window as a sibling of the main control panel. Useful when the default single-panel layout gets too tall or too narrow — panels can be placed side-by-side and sized independently.GuiPanelHandlesubclassesGuiFolderHandle, so it works as a context manager exactly like folders do — the only difference is that the panel renders as its own floating window instead of inline in the main panel.Features
localStorage(keyed by the panel's UUID).initial_position=(x, y)acceptsint | \"center\"for either axis. Negative integers anchor to the right/bottom edge (e.g.(-20, 20)is 20px from the top-right corner).layout=\"row\": renders children side-by-side with equal flex share, non-wrapping — useful for rows of camera/video feeds.resizingRefsuppresses the ResizeObserver's reposition pass during an active drag so width updates don't fight it.Backward-compatible: all changes are additive.
SidebarPanel,BottomPanel, and existingFloatingPanelcall sites are untouched.Demo
examples/02_gui/11_panels.py— standalone demo with animated "video" feeds. Shows the main panel alongside three user panels (top-left, centered, bottom-right), with working Zoom slider and Reset button. Run withpython examples/02_gui/11_panels.pyand open http://localhost:8080.Stats
13 files changed, 528 insertions(+), 6 deletions(-). Largest changes are in
UserPanels.tsx(new, 121 lines — the renderer) andFloatingPanel.tsx(+101, adds the resize handle andinitialPosition/onGeometryChangeprops).Test plan
examples/02_gui/11_panels.pyruns; all three panels visible and animate.\"center\"x keeps the Cameras panel horizontally centered; negative-y keeps Status anchored to the bottom.add_folder,configure_theme, sidebar layout, and bottom (mobile) layout are unchanged — verified via02_gui/00_basic_controls.pyand02_gui/05_theming.py.Open questions / happy to bikeshed
API shape wasn't obvious — would love maintainer input on any of these before you merge:
initial_positionconvention. I usedint | \"center\"with negative = right/bottom anchor. Clean in the common case, but the negative-sign thing is a little clever. An alternative would be an explicitanchor: Literal[\"top-left\", \"top-right\", \"top-center\", \"bottom-left\", \"bottom-right\"] = \"top-left\"field with all-positive offsets. Same expressiveness, more verbose.layout=\"row\". Currently only exists on panels. If this feels generally useful, it could move toadd_folder/ a newadd_rowcontainer. Kept it panel-only here to minimize surface area.UserPanels.tsxand persists by panel UUID. If uuids aren't stable across Python restarts (they aren't —uuid.uuid4()), persistence only survives browser reloads, not server restarts. Happy to key ontitleinstead if that's preferable, or make persistence opt-in via a prop.UserPanels.tsx, or leave it to the user.Also: I ran ruff (passes),
npm run typecheck(passes), and smoke-tested existing GUI examples (00_basic_controls.py,01_callbacks.py,05_theming.py). I couldn't runpyrightlocally due to an unrelated environment issue — CI should catch any type problems.🤖 Generated with Claude Code