Skip to content

Commit 1044af7

Browse files
committed
FEATURE: Add an explicit legend explaining the text background colors
1 parent c9e59cf commit 1044af7

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

MethodicConfigurator/frontend_tkinter_base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,16 @@ def __init__(self, *args, **kwargs):
314314
self.tag_configure("h1", font=h1_font, spacing3=default_size)
315315

316316

317+
def get_font_family(widget: tk.Widget) -> str:
318+
style = ttk.Style()
319+
widget_style = widget.cget("style") # Get the style used by the widget
320+
font_descriptions = style.lookup(widget_style, 'font')
321+
if font_descriptions:
322+
font_family = font_descriptions[0] # Font description is a tuple where the first element is the family
323+
return font_family
324+
return "Font family not found"
325+
326+
317327
class BaseWindow:
318328
"""
319329
A base class for creating windows in the ArduPilot Methodic Configurator application.

MethodicConfigurator/frontend_tkinter_parameter_editor.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from MethodicConfigurator.frontend_tkinter_base import ProgressWindow
3535
from MethodicConfigurator.frontend_tkinter_base import BaseWindow
3636
from MethodicConfigurator.frontend_tkinter_base import RichText
37+
from MethodicConfigurator.frontend_tkinter_base import get_font_family
3738

3839
from MethodicConfigurator.frontend_tkinter_directory_selection import VehicleDirectorySelectionWidgets
3940

@@ -188,7 +189,7 @@ def __init__(self, current_file: str, flight_controller: FlightController,
188189

189190
self.root.title("Amilcar Lucas's - ArduPilot methodic configurator " + version + \
190191
" - Parameter file editor and uploader")
191-
self.root.geometry("900x500") # Set the window width
192+
self.root.geometry("990x550") # Set the window width
192193

193194
# Bind the close_connection_and_quit function to the window close event
194195
self.root.protocol("WM_DELETE_WINDOW", self.close_connection_and_quit)
@@ -241,11 +242,40 @@ def __create_conf_widgets(self, version: str):
241242
self.file_selection_combobox.bind("<<ComboboxSelected>>", self.on_param_file_combobox_change)
242243
self.file_selection_combobox.pack(side=tk.TOP, anchor=tk.NW, pady=(4, 0))
243244

245+
self.legend_frame(config_subframe, get_font_family(file_selection_label))
246+
244247
image_label = BaseWindow.put_image_in_label(config_frame, LocalFilesystem.application_logo_filepath())
245248
image_label.pack(side=tk.RIGHT, anchor=tk.NE, padx=(4, 4), pady=(4, 0))
246249
image_label.bind("<Button-1>", lambda event: show_about_window(self.main_frame, version))
247250
show_tooltip(image_label, "User Manual, Support Forum, Report a Bug, Licenses, Source Code")
248251

252+
def legend_frame(self, config_subframe: ttk.Frame, font_family: str):
253+
style = ttk.Style()
254+
style.configure('Legend.TLabelframe', font=(font_family, 9))
255+
legend_frame = ttk.LabelFrame(config_subframe, text="Legend", style='Legend.TLabelframe')
256+
legend_left = ttk.Frame(legend_frame)
257+
legend_left.pack(side=tk.LEFT, anchor=tk.NW)
258+
show_tooltip(legend_frame, "the meaning of the text background colors")
259+
260+
font_size = 8
261+
font = (font_family, font_size)
262+
np_label = ttk.Label(legend_left, text="Normal parameter", font=font)
263+
np_label.pack(side=tk.TOP, anchor=tk.NW)
264+
cal_label = ttk.Label(legend_left, text="Calibration param", background="yellow", font=font)
265+
cal_label.pack(side=tk.TOP, anchor=tk.NW)
266+
readonly_label = ttk.Label(legend_left, text="Read-only param", background="red", font=font)
267+
readonly_label.pack(side=tk.TOP, anchor=tk.NW)
268+
legend_right = ttk.Frame(legend_frame)
269+
legend_right.pack(side=tk.RIGHT, anchor=tk.NE)
270+
default_label = ttk.Label(legend_right, text="Default value", background="lightblue", font=font)
271+
default_label.pack(side=tk.TOP, anchor=tk.NW)
272+
na_label = ttk.Label(legend_right, text="Not available", background="orange", font=font)
273+
na_label.pack(side=tk.TOP, anchor=tk.NW)
274+
ne_label = ttk.Label(legend_right, text="Not editable", font=font)
275+
ne_label.configure(state='disabled')
276+
ne_label.pack(side=tk.TOP, anchor=tk.NW)
277+
legend_frame.pack(side=tk.LEFT, fill="x", expand=False, padx=(2, 2))
278+
249279
def __create_parameter_area_widgets(self):
250280
self.show_only_differences = tk.BooleanVar(value=False)
251281
self.annotate_params_into_files = tk.BooleanVar(value=False)

0 commit comments

Comments
 (0)