33
33
try :
34
34
from textual .app import App , ComposeResult
35
35
from textual .containers import VerticalScroll
36
+ from textual .screen import Screen
36
37
from textual .widgets import Button , Header , Label
37
38
except ImportError :
38
39
print ("Please install the \" textual-dev\" package before running this script." )
42
43
from editor import EditorScreen
43
44
from compile import CompileScreen
44
45
45
- class ConfigEditorApp (App ):
46
- # Main application class
47
-
48
- # Set the root and script paths
49
- SCRIPT_PATH = os .path .abspath (os .path .dirname (__file__ ))
50
- ROOT_PATH = os .path .abspath (os .path .join (SCRIPT_PATH , ".." , ".." ))
51
-
52
- # Set the application options
53
- setting_enable_copy = True
54
-
55
- # Options to be set by the command line arguments
56
- setting_target = ""
57
- setting_arduino_path = ""
58
- setting_arduino_branch = ""
59
- setting_idf_branch = ""
60
- setting_idf_commit = ""
61
- setting_debug_level = ""
62
-
63
- ENABLE_COMMAND_PALETTE = False
64
- CSS_PATH = "style.tcss"
65
- SCREENS = {
66
- "settings" : SettingsScreen (),
67
- "compile" : CompileScreen (),
68
- "editor" : EditorScreen (),
69
- }
46
+ class MainScreen (Screen ):
47
+ # Main screen class
70
48
71
49
def on_button_pressed (self , event : Button .Pressed ) -> None :
72
50
# Event handler called when a button is pressed
73
51
if event .button .id == "compile-button" :
74
52
print ("Compile button pressed" )
75
- self .push_screen ("compile" )
53
+ self .app . push_screen ("compile" )
76
54
elif event .button .id == "settings-button" :
77
55
print ("Settings button pressed" )
78
- self .push_screen ("settings" )
56
+ self .app . push_screen ("settings" )
79
57
elif event .button .id == "editor-button" :
80
58
print ("Editor button pressed" )
81
- self .push_screen ("editor" )
59
+ self .app . push_screen ("editor" )
82
60
elif event .button .id == "quit-button" :
83
61
print ("Quit button pressed" )
84
62
quit ()
@@ -99,15 +77,45 @@ def on_mount(self) -> None:
99
77
self .sub_title = "Main Menu"
100
78
print ("Using Python version: " + sys .version )
101
79
print ("App started. Initial Options:" )
102
- print ("Root path: " + self .ROOT_PATH )
103
- print ("Script path: " + self .SCRIPT_PATH )
104
- print ("Target: " + str (self .setting_target ))
105
- print ("Enable Copy: " + str (self .setting_enable_copy ))
106
- print ("Arduino Path: " + str (self .setting_arduino_path ))
107
- print ("Arduino Branch: " + str (self .setting_arduino_branch ))
108
- print ("IDF Branch: " + str (self .setting_idf_branch ))
109
- print ("IDF Commit: " + str (self .setting_idf_commit ))
110
- print ("IDF Debug Level: " + str (self .setting_debug_level ))
80
+ print ("Root path: " + self .app .ROOT_PATH )
81
+ print ("Script path: " + self .app .SCRIPT_PATH )
82
+ print ("Target: " + str (self .app .setting_target ))
83
+ print ("Enable Copy: " + str (self .app .setting_enable_copy ))
84
+ print ("Arduino Path: " + str (self .app .setting_arduino_path ))
85
+ print ("Arduino Branch: " + str (self .app .setting_arduino_branch ))
86
+ print ("IDF Branch: " + str (self .app .setting_idf_branch ))
87
+ print ("IDF Commit: " + str (self .app .setting_idf_commit ))
88
+ print ("IDF Debug Level: " + str (self .app .setting_debug_level ))
89
+
90
+ class ConfigEditorApp (App ):
91
+ # Main application class
92
+
93
+ # Set the root and script paths
94
+ SCRIPT_PATH = os .path .abspath (os .path .dirname (__file__ ))
95
+ ROOT_PATH = os .path .abspath (os .path .join (SCRIPT_PATH , ".." , ".." ))
96
+
97
+ # Set the application options
98
+ setting_enable_copy = True
99
+
100
+ # Options to be set by the command line arguments
101
+ setting_target = ""
102
+ setting_arduino_path = ""
103
+ setting_arduino_branch = ""
104
+ setting_idf_branch = ""
105
+ setting_idf_commit = ""
106
+ setting_debug_level = ""
107
+
108
+ ENABLE_COMMAND_PALETTE = False
109
+ CSS_PATH = "style.tcss"
110
+ SCREENS = {
111
+ "main" : MainScreen (),
112
+ "settings" : SettingsScreen (),
113
+ "compile" : CompileScreen (),
114
+ "editor" : EditorScreen (),
115
+ }
116
+
117
+ def on_mount (self ) -> None :
118
+ self .push_screen ("main" )
111
119
112
120
def arduino_default_path ():
113
121
sys_name = platform .system ()
0 commit comments