1- from trame .app import get_server
2- from trame .ui .vuetify import SinglePageLayout
3- from trame .widgets import html , vtk , vuetify
1+ from trame .app import TrameApp
2+ from trame .ui .vuetify3 import SinglePageLayout
3+ from trame .widgets import html , vtk , vuetify3
44
55
6- class Cone :
6+ class Cone ( TrameApp ) :
77 def __init__ (self , name = None ):
8- self .server = get_server (name , client_type = "vue2" )
9- self ._ui = None
10-
11- # Build UI
12- self .ui
13-
14- @property
15- def state (self ):
16- return self .server .state
17-
18- @property
19- def ctrl (self ):
20- return self .server .controller
8+ super ().__init__ (server = name )
9+ self ._build_ui ()
2110
2211 @property
2312 def resolution (self ):
@@ -31,25 +20,21 @@ def resolution(self, v):
3120 def reset_resolution (self ):
3221 self .resolution = 6
3322
34- @property
35- def ui (self ):
36- if self ._ui is None :
37- with SinglePageLayout (self .server ) as layout :
38- self ._ui = layout
39- with layout .toolbar :
40- html .Div ("a: {{ a }}" )
41- vuetify .VSpacer ()
42- vuetify .VSlider (
43- v_model = ("resolution" , 6 ), min = 3 , max = 60 , hide_details = True
44- )
45- vuetify .VBtn ("Reset" , click = self .reset_resolution )
46- with layout .content :
47- with vuetify .VContainer (fluid = True , classes = "pa-0 fill-height" ):
48- with vtk .VtkView () as vtk_view :
49- self .ctrl .reset_camera = vtk_view .reset_camera
50- with vtk .VtkGeometryRepresentation ():
51- vtk .VtkAlgorithm (
52- vtkClass = "vtkConeSource" , state = ("{ resolution }" ,)
53- )
54-
55- return self ._ui
23+ def _build_ui (self ):
24+ with SinglePageLayout (self .server ) as self .ui :
25+ self .ui .icon .click = self .ctrl .reset_camera
26+ with self .ui .toolbar :
27+ html .Div ("resolution: {{ resolution }}" )
28+ vuetify3 .VSpacer ()
29+ vuetify3 .VSlider (
30+ v_model = ("resolution" , 6 ), min = 3 , max = 60 , step = 1 , hide_details = True
31+ )
32+ vuetify3 .VBtn ("Reset" , click = self .reset_resolution )
33+ with self .ui .content :
34+ with vuetify3 .VContainer (fluid = True , classes = "pa-0 fill-height" ):
35+ with vtk .VtkView () as vtk_view :
36+ self .ctrl .reset_camera = vtk_view .reset_camera
37+ with vtk .VtkGeometryRepresentation ():
38+ vtk .VtkAlgorithm (
39+ vtkClass = "vtkConeSource" , state = ("{ resolution }" ,)
40+ )
0 commit comments