Skip to content

Commit d90902b

Browse files
committed
python: Remove styling
I don't like the styling. And if we do want to change the styling we should use the built-in styling/theming facility instead of building it from scratch. https://tkdocs.com/tutorial/styles.html Signed-off-by: Daniel Schaefer <[email protected]>
1 parent ebcac52 commit d90902b

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

python/inputmodule/gui/__init__.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,6 @@ def run_gui(devices):
5656
tabControl.add(tab3, text="Advanced")
5757
tabControl.pack(expand=1, fill="both")
5858

59-
# Configure dark theme
60-
style = ttk.Style()
61-
root.configure(bg="#2b2b2b")
62-
style.configure("TLabelframe", background="#2b2b2b", foreground="white")
63-
style.configure("TLabelframe.Label", background="#2b2b2b", foreground="white")
64-
style.configure("TCheckbutton", background="#2b2b2b", foreground="white")
65-
if platform.system() == "Windows": # On Windows, I don't know why background always stays white even if I set it to black
66-
style.configure("TButton", background="white", foreground="#2b2b2b")
67-
else:
68-
style.configure("TButton", background="#2b2b2b", foreground="white")
69-
style.configure("TEntry", fieldbackground="#2b2b2b", foreground="white")
70-
style.configure("TCombobox", fieldbackground="#2b2b2b", foreground="white")
71-
style.configure("TScale", background="#2b2b2b", troughcolor="gray")
72-
style.configure("TSpinbox", background="#2b2b2b", foreground="white")
73-
style.map("TButton", background=[("active", "gray"), ("!active", "#2b2b2b")])
74-
7559
# Device Checkboxes
7660
detected_devices_frame = ttk.LabelFrame(root, text="Detected Devices", style="TLabelframe")
7761
detected_devices_frame.pack(fill="x", padx=10, pady=5)
@@ -103,7 +87,7 @@ def run_gui(devices):
10387
brightness_frame = ttk.LabelFrame(tab1, text="Brightness", style="TLabelframe")
10488
brightness_frame.pack(fill="x", padx=10, pady=5)
10589
global brightness_scale
106-
brightness_scale = tk.Scale(brightness_frame, from_=0, to=255, orient='horizontal', command=lambda value: set_brightness(devices, value), bg="#2b2b2b", fg="white", troughcolor="gray", highlightbackground="#2b2b2b")
90+
brightness_scale = tk.Scale(brightness_frame, from_=0, to=255, orient='horizontal', command=lambda value: set_brightness(devices, value))
10791
brightness_scale.set(120) # Default value
10892
brightness_scale.pack(fill="x", padx=5, pady=5)
10993

@@ -120,20 +104,20 @@ def run_gui(devices):
120104
# Pattern Combo Box
121105
pattern_frame = ttk.LabelFrame(tab1, text="Pattern", style="TLabelframe")
122106
pattern_frame.pack(fill="x", padx=10, pady=5)
123-
pattern_combo = ttk.Combobox(pattern_frame, values=PATTERNS, style="TCombobox")
107+
pattern_combo = ttk.Combobox(pattern_frame, values=PATTERNS, style="TCombobox", state="readonly")
124108
pattern_combo.pack(fill="x", padx=5, pady=5)
125109
pattern_combo.bind("<<ComboboxSelected>>", lambda event: set_pattern(devices, pattern_combo.get()))
126110

127111
# Percentage Slider
128112
percentage_frame = ttk.LabelFrame(tab1, text="Fill screen X% (could be volume indicator)", style="TLabelframe")
129113
percentage_frame.pack(fill="x", padx=10, pady=5)
130-
percentage_scale = tk.Scale(percentage_frame, from_=0, to=100, orient='horizontal', command=lambda value: set_percentage(devices, value), bg="#2b2b2b", fg="white", troughcolor="gray", highlightbackground="#2b2b2b")
114+
percentage_scale = tk.Scale(percentage_frame, from_=0, to=100, orient='horizontal', command=lambda value: set_percentage(devices, value))
131115
percentage_scale.pack(fill="x", padx=5, pady=5)
132116

133117
# Countdown Timer
134118
countdown_frame = ttk.LabelFrame(tab2, text="Countdown Timer", style="TLabelframe")
135119
countdown_frame.pack(fill="x", padx=10, pady=5)
136-
countdown_spinbox = tk.Spinbox(countdown_frame, from_=1, to=60, width=5, bg="#2b2b2b", fg="white", textvariable=tk.StringVar(value=10))
120+
countdown_spinbox = tk.Spinbox(countdown_frame, from_=1, to=60, width=5, textvariable=tk.StringVar(value=10))
137121
countdown_spinbox.pack(side="left", padx=5, pady=5)
138122
ttk.Label(countdown_frame, text="Seconds", style="TLabel").pack(side="left")
139123
ttk.Button(countdown_frame, text="Start", command=lambda: start_countdown(devices, countdown_spinbox.get()), style="TButton").pack(side="left", padx=5, pady=5)
@@ -166,7 +150,7 @@ def run_gui(devices):
166150
# PWM Frequency Combo Box
167151
pwm_freq_frame = ttk.LabelFrame(tab3, text="PWM Frequency", style="TLabelframe")
168152
pwm_freq_frame.pack(fill="x", padx=10, pady=5)
169-
pwm_freq_combo = ttk.Combobox(pwm_freq_frame, values=PWM_FREQUENCIES, style="TCombobox")
153+
pwm_freq_combo = ttk.Combobox(pwm_freq_frame, values=PWM_FREQUENCIES, style="TCombobox", state="readonly")
170154
pwm_freq_combo.pack(fill="x", padx=5, pady=5)
171155
pwm_freq_combo.bind("<<ComboboxSelected>>", lambda: set_pwm_freq(devices, pwm_freq_combo.get()))
172156

0 commit comments

Comments
 (0)