From cac5f9c116b90cd3f917089bbb8e0448253ba2f8 Mon Sep 17 00:00:00 2001 From: Blake Ridgway Date: Sat, 5 Apr 2025 18:02:49 -0500 Subject: [PATCH] refactor: Centralize UI component creation This commit centralizes the creation of common UI components into `ui/components.py`, promoting code reuse and consistency. - Created functions for creating labels, entries, buttons, combos, and text boxes. - Replaced direct widget creation in MainWindow with calls to these functions. --- ui/components.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ui/components.py diff --git a/ui/components.py b/ui/components.py new file mode 100644 index 0000000..26008ff --- /dev/null +++ b/ui/components.py @@ -0,0 +1,22 @@ +# timelogix/ui/components.py +import customtkinter as ctk + + +def create_label(parent, text, font_family, font_size): + return ctk.CTkLabel(parent, text=text, font=(font_family, font_size)) + + +def create_entry(parent, width): + return ctk.CTkEntry(parent, width=width) + + +def create_button(parent, text, command): + return ctk.CTkButton(parent, text=text, command=command, corner_radius=8) + + +def create_combo(parent, values, width): + return ctk.CTkComboBox(parent, values=values, width=width) + + +def create_text_box(parent, width, height, font): + return ctk.CTkTextbox(parent, width=width, height=height, font=font)