Skip to content

Commit b118528

Browse files
committed
Add remaining settings
1 parent bb13cc0 commit b118528

File tree

4 files changed

+71
-22
lines changed

4 files changed

+71
-22
lines changed

tools/config_editor/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
try:
2323
from textual.app import App, ComposeResult
24-
from textual.containers import Container
24+
from textual.containers import VerticalScroll
2525
from textual.widgets import Button, Header, Label
2626
except ImportError:
2727
print("Please install the \"textual-dev\" package before running this script.")
@@ -76,7 +76,7 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
7676
def compose(self) -> ComposeResult:
7777
# Compose main menu
7878
yield Header()
79-
with Container(id="main-menu-container"):
79+
with VerticalScroll(id="main-menu-container"):
8080
yield Label("ESP32 Arduino Static Libraries Configuration Editor", id="main-menu-title")
8181
yield Button("Compile Static Libraries", id="compile-button", classes="main-menu-button")
8282
yield Button("Change sdkconfig Flags", id="editor-button", classes="main-menu-button")

tools/config_editor/settings.py

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,48 @@
33
from textual.containers import VerticalScroll, Container, Horizontal
44
from textual.screen import Screen
55
from textual.events import ScreenResume
6-
from textual.widgets import Header, Button, Switch
6+
from textual.widgets import Header, Button, Switch, Label
77

88
from widgets import LabelledInput, LabelledSelect
99

1010
class SettingsScreen(Screen):
1111
# Settings screen
1212

13+
target_select: LabelledSelect
14+
enable_copy_switch: Switch
15+
arduino_path_input: LabelledInput
16+
arduino_branch_input: LabelledInput
17+
idf_branch_input: LabelledInput
18+
idf_commit_input: LabelledInput
19+
idf_debug_select: LabelledSelect
20+
1321
def on_button_pressed(self, event: Button.Pressed) -> None:
1422
# Event handler called when a button is pressed
1523
if event.button.id == "save-settings-button":
1624
print("Save button pressed")
1725

18-
# Update the target setting
19-
self.app.setting_target = self.query_one("#target-select", LabelledSelect).get_select_value()
26+
self.app.setting_target = self.target_select.get_select_value()
2027
print("Target setting updated: " + self.app.setting_target)
2128

29+
self.app.setting_enable_copy = self.enable_copy_switch.value
30+
print("Enable copy setting updated: " + str(self.app.setting_enable_copy))
31+
32+
if self.enable_copy_switch.value:
33+
self.app.setting_arduino_path = self.arduino_path_input.get_input_value()
34+
print("Arduino path setting updated: " + self.app.setting_arduino_path)
35+
36+
self.app.setting_arduino_branch = self.arduino_branch_input.get_input_value()
37+
print("Arduino branch setting updated: " + self.app.setting_arduino_branch)
38+
39+
self.app.setting_idf_branch = self.idf_branch_input.get_input_value()
40+
print("IDF branch setting updated: " + self.app.setting_idf_branch)
41+
42+
self.app.setting_idf_commit = self.idf_commit_input.get_input_value()
43+
print("IDF commit setting updated: " + self.app.setting_idf_commit)
44+
45+
self.app.setting_debug_level = self.idf_debug_select.get_select_value()
46+
print("Debug level setting updated: " + self.app.setting_debug_level)
47+
2248
self.dismiss()
2349
elif event.button.id == "cancel-settings-button":
2450
print("Cancel button pressed")
@@ -28,9 +54,13 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
2854
def on_resume(self) -> None:
2955
# Event handler called every time the screen is activated
3056
print("Settings screen resumed. Updating settings.")
31-
32-
# Update Target selection
33-
self.query_one("#target-select", LabelledSelect).set_select_value(self.app.setting_target)
57+
self.target_select.set_select_value(self.app.setting_target)
58+
self.enable_copy_switch.value = self.app.setting_enable_copy
59+
self.arduino_path_input.set_input_value(self.app.setting_arduino_path)
60+
self.arduino_branch_input.set_input_value(self.app.setting_arduino_branch)
61+
self.idf_branch_input.set_input_value(self.app.setting_idf_branch)
62+
self.idf_commit_input.set_input_value(self.app.setting_idf_commit)
63+
self.idf_debug_select.set_select_value(self.app.setting_debug_level)
3464

3565
def compose(self) -> ComposeResult:
3666
# Compose the target selection screen
@@ -46,11 +76,38 @@ def compose(self) -> ComposeResult:
4676
("ESP32-C6", "esp32c6"),
4777
("ESP32-H2", "esp32h2")
4878
]
49-
yield LabelledSelect("Compilation Target", target_options, id="target-select", classes="settings-select", allow_blank=False)
79+
self.target_select = LabelledSelect("Compilation Target", target_options, allow_blank=False, id="target-select")
80+
yield self.target_select
81+
5082
with Horizontal(id="settings-enable-copy-container"):
51-
yield Switch(id="enable-copy-switch", classes="settings-switch", value=self.app.setting_enable_copy)
52-
yield LabelledInput("Arduino-esp32 Path", placeholder="Path to your arduino-esp32 installation", value=self.app.setting_arduino_path)
53-
yield LabelledInput("Arduino-esp32 Branch", placeholder="Leave empty to use default", value=self.app.setting_arduino_branch)
83+
yield Label("Copy to arduino-esp32 after compilation", id="enable-copy-label")
84+
85+
self.enable_copy_switch = Switch(value=self.app.setting_enable_copy, id="enable-copy-switch")
86+
yield self.enable_copy_switch
87+
88+
self.arduino_path_input = LabelledInput("Arduino-esp32 Path", placeholder="Path to your arduino-esp32 installation", value=self.app.setting_arduino_path, id="arduino-path-input")
89+
yield self.arduino_path_input
90+
91+
self.arduino_branch_input = LabelledInput("Arduino-esp32 Branch", placeholder="Leave empty to use default", value=self.app.setting_arduino_branch, id="arduino-branch-input")
92+
yield self.arduino_branch_input
93+
94+
self.idf_branch_input = LabelledInput("ESP-IDF Branch", placeholder="Leave empty to use default", value=self.app.setting_idf_branch, id="idf-branch-input")
95+
yield self.idf_branch_input
96+
97+
self.idf_commit_input = LabelledInput("ESP-IDF Commit", placeholder="Leave empty to use default", value=self.app.setting_idf_commit, id="idf-commit-input")
98+
yield self.idf_commit_input
99+
100+
debug_options = [
101+
("Default", "default"),
102+
("None", "none"),
103+
("Error", "error"),
104+
("Warning", "warning"),
105+
("Info", "info"),
106+
("Debug", "debug"),
107+
("Verbose", "verbose")
108+
]
109+
self.idf_debug_select = LabelledSelect("ESP-IDF Debug Level", debug_options, allow_blank=False, id="idf-debug-select")
110+
yield self.idf_debug_select
54111

55112
with Horizontal(id="settings-button-container"):
56113
yield Button("Save", id="save-settings-button", classes="settings-button")

tools/config_editor/style.tcss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ Button.main-menu-button {
5555

5656
# Settings Screen
5757

58-
#settings-radioset {
59-
align: center middle;
60-
width: 0.4fr;
61-
}
62-
6358
#settings-scroll-container {
6459
align: center middle;
6560
padding: 1;
@@ -79,10 +74,6 @@ Button.main-menu-button {
7974
align: center middle;
8075
}
8176

82-
.settings-labelled-input {
83-
margin: 1;
84-
}
85-
8677
# Editor Screen
8778

8879
#tree-view {

tools/config_editor/widgets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
class LabelledInput(Widget):
66
DEFAULT_CSS = """
77
LabelledInput {
8-
width: 1fr;
98
height: 4;
9+
margin-bottom: 1;
1010
}
1111
LabelledInput Label {
1212
padding-left: 1;
@@ -47,6 +47,7 @@ class LabelledSelect(Widget):
4747
DEFAULT_CSS = """
4848
LabelledSelect {
4949
height: 4;
50+
margin-bottom: 1;
5051
}
5152
LabelledSelect Label {
5253
padding-left: 1;

0 commit comments

Comments
 (0)