Skip to content

Commit f57c152

Browse files
committed
WIP
1 parent 6b69bb3 commit f57c152

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,17 @@ def __init__(self, current_file: str, flight_controller: FlightController, local
171171
self.__create_conf_widgets(__version__)
172172

173173
# Get the first two characters of the last configuration step filename
174-
last_step_filename = next(reversed(self.local_filesystem.configuration_steps.keys()))
175-
last_step_nr = int(last_step_filename[:2])+1 if len(last_step_filename) >= 2 else 0
174+
last_step_filename = next(reversed(self.local_filesystem.file_parameters.keys()))
175+
last_step_nr = int(last_step_filename[:2]) + 1 if len(last_step_filename) >= 2 else 1
176176

177-
stage_progress_bar = StageProgressBar(self.main_frame, self.local_filesystem.configuration_phases, last_step_nr)
178-
stage_progress_bar.pack(side=tk.TOP, fill="x", expand=False, pady=(4, 4), padx=(4, 4)) # Pack the frame at the top of the window
177+
self.stage_progress_bar = StageProgressBar(self.main_frame, self.local_filesystem.configuration_phases, last_step_nr)
178+
self.stage_progress_bar.pack(
179+
side=tk.TOP, fill="x", expand=False, pady=(2, 2), padx=(4, 4)
180+
) # Pack the frame at the top of the window
179181

180182
# Create a DocumentationFrame object for the Documentation Content
181183
self.documentation_frame = DocumentationFrame(self.main_frame, self.local_filesystem, self.current_file)
184+
self.documentation_frame.documentation_frame.pack(side=tk.TOP, fill="x", expand=False, pady=(2, 2), padx=(4, 4))
182185

183186
self.__create_parameter_area_widgets()
184187

@@ -504,6 +507,7 @@ def on_param_file_combobox_change(self, _event: Union[None, tk.Event], forced: b
504507
selected_file = self.file_selection_combobox.get()
505508
if self.current_file != selected_file or forced:
506509
self.write_changes_to_intermediate_parameter_file()
510+
self.stage_progress_bar.update_progress(int(selected_file[:2]))
507511
self.__do_tempcal_imu(selected_file)
508512
self.__should_copy_fc_values_to_file(selected_file)
509513
selected_file = self.__should_jump_to_file(selected_file)

ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_documentation_frame.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def __init__(self, root: tk.Widget, local_filesystem: LocalFilesystem, current_f
4242

4343
def __create_documentation_frame(self) -> None:
4444
self.documentation_frame = ttk.LabelFrame(self.root, text=_("Documentation"))
45-
self.documentation_frame.pack(side=tk.TOP, fill="x", expand=False, pady=(4, 4), padx=(4, 4))
4645

4746
# Create a grid structure within the documentation_frame
4847
documentation_grid = ttk.Frame(self.documentation_frame)

ardupilot_methodic_configurator/frontend_tkinter_stage_progress.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import tkinter as tk
2626
from logging import basicConfig as logging_basicConfig
2727
from logging import getLevelName as logging_getLevelName
28+
from logging import error as logging_error
2829
from tkinter import ttk
2930
from typing import Union
3031

@@ -49,6 +50,13 @@ def __init__(self, master: tk.Widget, phases: dict[str, dict], total_steps: int,
4950

5051
self.create_phase_frames()
5152
self.bind("<Configure>", self._on_resize)
53+
show_tooltip(
54+
self,
55+
_(
56+
"This bar shows your progress through the configuration phases. Each phase contains configuration steps that must be completed in sequence."
57+
),
58+
position_below=False,
59+
)
5260

5361
def create_phase_frames(self) -> None:
5462
"""Create frames for each phase with progress bars and labels."""
@@ -91,17 +99,25 @@ def create_phase_frames(self) -> None:
9199
if "\n" not in label_text and len(label_text) < 20:
92100
label_text += "\n "
93101

102+
# Use gray text color if phase is marked as optional
103+
is_optional = phase_data.get("optional", False)
104+
label_fg = "gray" if is_optional else "black"
105+
94106
label = ttk.Label(
95107
frame,
96108
text=label_text,
97109
wraplength=0, # Will be updated in _on_resize
98110
justify=tk.CENTER,
99111
anchor="center",
112+
foreground=label_fg,
100113
)
101114
label.grid(row=1, column=0, sticky="ew")
102115

103116
self.phase_frames[phase_name] = frame
104-
show_tooltip(frame, phase_data.get("description", ""))
117+
tooltip_msg = _(phase_data.get("description", ""))
118+
if is_optional:
119+
tooltip_msg += "\n" + _("This phase is optional.")
120+
show_tooltip(frame, tooltip_msg)
105121
self.phase_bars.append({"bar": progress, "start": start, "end": end})
106122

107123
def _on_resize(self, _event: Union[tk.Event, None] = None) -> None:
@@ -133,6 +149,12 @@ def update_progress(self, current_file: int) -> None:
133149
- Show progress between start-end otherwise
134150
135151
"""
152+
if not (0 < current_file < self.total_files):
153+
msg = _("Out of expected range [0 .. {self.total_files}] current file number: {current_file}")
154+
msg = msg.format(self=self, current_file=current_file)
155+
logging_error(msg)
156+
return
157+
136158
for phase in self.phase_bars:
137159
if phase["start"] <= current_file <= phase["end"]:
138160
# Calculate progress within this phase

0 commit comments

Comments
 (0)