Skip to content

Commit adfd845

Browse files
committed
docs(examples): use TrameApp in 04_application
1 parent 32e9c35 commit adfd845

2 files changed

Lines changed: 439 additions & 424 deletions

File tree

04_application/app.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import os
22

3-
from trame.app import get_server
3+
from trame.app import TrameApp
44
from trame.ui.vuetify3 import SinglePageLayout
5-
from trame.widgets import vtk, vuetify3
5+
from trame.widgets import vuetify3 as v3
6+
from trame.widgets import vtk, trame
7+
from trame.decorators import change
68

79
from vtkmodules.vtkRenderingCore import (
810
vtkActor,
@@ -62,8 +64,9 @@
6264
# Trame setup
6365
# -----------------------------------------------------------------------------
6466

65-
server = get_server()
66-
state, ctrl = server.state, server.controller
67+
class App(TrameApp):
68+
def __init__(self, server=None):
69+
super().__init__(server)
6770

6871
# -----------------------------------------------------------------------------
6972
# Callbacks
@@ -77,26 +80,31 @@
7780
# GUI
7881
# -----------------------------------------------------------------------------
7982

80-
with SinglePageLayout(server) as layout:
81-
layout.title.set_text("Viewer")
83+
def _build_ui(self):
84+
with SinglePageLayout(self.server) as self.ui:
85+
self.ui.title.set_text("Viewer")
8286

83-
with layout.toolbar:
84-
# toolbar components
85-
pass
87+
with self.ui.toolbar:
88+
# toolbar components
89+
pass
8690

87-
with layout.content:
88-
# content components
89-
with vuetify3.VContainer(
90-
fluid=True,
91-
classes="pa-0 fill-height",
92-
):
93-
view = vtk.VtkLocalView(renderWindow)
94-
ctrl.view_update = view.update
95-
ctrl.view_reset_camera = view.reset_camera
91+
with self.ui.content:
92+
# content components
93+
with v3.VContainer(
94+
fluid=True,
95+
classes="pa-0 fill-height",
96+
):
97+
view = vtk.VtkLocalView(renderWindow)
98+
self.ctrl.view_update = view.update
99+
self.ctrl.view_reset_camera = view.reset_camera
96100

97101
# -----------------------------------------------------------------------------
98102
# Main
99103
# -----------------------------------------------------------------------------
100104

105+
def main():
106+
app = App()
107+
app.server.start()
108+
101109
if __name__ == "__main__":
102-
server.start()
110+
main()

0 commit comments

Comments
 (0)