33from nova .mvvm .trame_binding import TrameBinding
44from nova .trame import ThemedApp
55from nova .trame .view .components import InputField
6- from nova .trame .view .layouts import VBoxLayout
7- from trame .widgets import client
6+ from nova .trame .view .layouts import GridLayout , VBoxLayout
87from trame .widgets import vuetify3 as vuetify
98
109from .model import Model
@@ -20,34 +19,33 @@ def __init__(self) -> None:
2019 self .create_vm ()
2120 # If you forget to call connect, then the application will crash when you attempt to update the view.
2221 self .view_model .form_data_bind .connect ("data" )
23- self .view_model .view_state_bind .connect ("state" )
2422
2523 self .create_ui ()
2624
2725 def create_ui (self ) -> None :
28- with super ().create_ui () as layout :
29- # This instructs the user interface to reset itself to the most recent valid state when a browser connects
30- # to the tool or the browser is refreshed. This is not appropriate for all situations, so it is not a
31- # default behavior at this time. You can disable this line and then refresh your browser while the user
32- # interface is in an error state to see the difference between the two behaviors.
33- client .ClientTriggers (mounted = self .view_model .init_view )
26+ self .set_theme ("CompactTheme" )
3427
28+ with super ().create_ui () as layout :
3529 with layout .pre_content :
3630 vuetify .VBanner (
3731 "The form is in an error state." ,
38- v_if = "state. errors?.length > 0" ,
32+ v_if = "errors.data ?.length > 0" ,
3933 color = "error" ,
4034 icon = "mdi-close" ,
4135 )
4236
4337 with layout .content :
44- with VBoxLayout (classes = "mb-2" ):
38+ with GridLayout (classes = "mb-2" , columns = 2 , gap = "0.5em" ):
39+ InputField (v_model = "data.num_banks" )
4540 InputField (v_model = "data.wavelength" )
4641 with VBoxLayout (halign = "center" ):
47- vuetify .VBtn ("{{ state.button_text }}" , disabled = ("state.errors?.length > 0" ,))
42+ vuetify .VBtn (
43+ "{{ errors.data?.length > 0 ? 'Errors Present' : 'No Errors' }}" ,
44+ disabled = ("errors.data?.length > 0" ,),
45+ )
4846
4947 with layout .post_content :
50- vuetify .VAlert ("{{ state. errors }}" , v_if = "state. errors?.length > 0" , color = "error" )
48+ vuetify .VAlert ("{{ errors.data }}" , v_if = "errors.data ?.length > 0" , color = "error" )
5149
5250 def create_vm (self ) -> None :
5351 binding = TrameBinding (self .state )
0 commit comments