diff --git a/docs/api/source/core.server.rst b/docs/api/source/core.server.rst index 8fa05b15..c2feeb6e 100644 --- a/docs/api/source/core.server.rst +++ b/docs/api/source/core.server.rst @@ -9,3 +9,4 @@ server core.state core.controller + core.vn_manager diff --git a/docs/api/source/core.vn_manager.rst b/docs/api/source/core.vn_manager.rst new file mode 100644 index 00000000..4e9db35d --- /dev/null +++ b/docs/api/source/core.vn_manager.rst @@ -0,0 +1,5 @@ +ui +===== + +.. autoclass:: trame_server.ui.VirtualNodeManager + :members: diff --git a/examples/05_charts/Plotly/01_plotly-charts-resizable.py b/examples/05_charts/Plotly/01_plotly-charts-resizable.py index 608a0fc6..7555cda6 100644 --- a/examples/05_charts/Plotly/01_plotly-charts-resizable.py +++ b/examples/05_charts/Plotly/01_plotly-charts-resizable.py @@ -152,8 +152,8 @@ def create_streamline_fig(width=100, height=100, **kwargs): x = np.linspace(-3, 3, 100) y = np.linspace(-3, 3, 100) Y, X = np.meshgrid(x, y) - u = -1 - X**2 + Y - v = 1 + X - Y**2 + u = -1 - X ** 2 + Y + v = 1 + X - Y ** 2 # Create streamline figure fig = ff.create_streamline( diff --git a/examples/validation/core/19_virtual_node.py b/examples/validation/core/19_virtual_node.py new file mode 100644 index 00000000..101c53b7 --- /dev/null +++ b/examples/validation/core/19_virtual_node.py @@ -0,0 +1,84 @@ +from trame.app import get_server +from trame.widgets import vtk, vuetify +from trame.ui.vuetify import SinglePageLayout + +# ----------------------------------------------------------------------------- +# trame +# ----------------------------------------------------------------------------- + +server = get_server( + # log_network="/Users/sebastien.jourdain/Documents/code/open-source/Web/trame-next/test-examples/logs", +) +state, ui = server.state, server.ui + +state.toolbar_version = 0 + +# ----------------------------------------------------------------------------- +# Methods +# ----------------------------------------------------------------------------- + + +@state.change("toolbar_version") +def udpate_toolbar(toolbar_version=0, **kwargs): + if toolbar_version == 1: + toolbar_2() + elif toolbar_version == 2: + toolbar_3() + else: + toolbar_1() + + +# ----------------------------------------------------------------------------- +# GUI (VirtualNodes) +# ----------------------------------------------------------------------------- + + +def toolbar_1(): + with ui.toolbar as tb: + tb.clear() + tb.add_child("Toolbar 1") + vuetify.VSpacer() + ui.toolbar_selector() + + +def toolbar_2(): + with ui.toolbar as tb: + tb.clear() + tb.add_child("Toolbar 2") + vuetify.VSpacer() + ui.toolbar_selector() + + +def toolbar_3(): + with ui.toolbar as tb: + tb.clear() + tb.add_child("Toolbar 3") + vuetify.VSpacer() + ui.toolbar_selector() + + +with ui.toolbar_selector: + with vuetify.VBtnToggle(v_model="toolbar_version"): + with vuetify.VBtn(): + vuetify.VIcon("mdi-numeric-1-circle") + with vuetify.VBtn(): + vuetify.VIcon("mdi-numeric-2-circle") + with vuetify.VBtn(): + vuetify.VIcon("mdi-numeric-3-circle") + + +# ----------------------------------------------------------------------------- +# GUI (Layout) +# ----------------------------------------------------------------------------- + +with SinglePageLayout(server) as layout: + with layout.toolbar as tb: + tb.clear() + ui.toolbar(layout) + +# ----------------------------------------------------------------------------- +# Main +# ----------------------------------------------------------------------------- + +if __name__ == "__main__": + server.start() diff --git a/setup.cfg b/setup.cfg index a75efd1f..ab1713d5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,14 +26,14 @@ keywords = packages = find: include_package_data = True install_requires = - trame-client + trame-client>=2.1.0 trame-components trame-deckgl trame-markdown trame-matplotlib trame-plotly trame-router - trame-server + trame-server>=2.1.0 trame-vega trame-vtk trame-vuetify diff --git a/trame/app/__init__.py b/trame/app/__init__.py index 241491b3..9ef0799b 100644 --- a/trame/app/__init__.py +++ b/trame/app/__init__.py @@ -1,5 +1,6 @@ from trame_server import Server from trame_client import module +from trame_client.widgets.core import VirtualNode DEFAULT_NAME = "trame" AVAILABLE_SERVERS = {} @@ -33,7 +34,7 @@ def get_server(name=None, create_if_missing=True, **kwargs): return AVAILABLE_SERVERS[name] if create_if_missing: - server = Server(name, **kwargs) + server = Server(name, VirtualNode, **kwargs) server.enable_module(module) # Always load html module first AVAILABLE_SERVERS[name] = server return server