Skip to content
This repository was archived by the owner on Apr 20, 2025. It is now read-only.

Commit 01d435e

Browse files
committed
Only add color_extra controls if the keyboard supports it
1 parent b9e4c51 commit 01d435e

File tree

1 file changed

+12
-7
lines changed
  • src/usr/share/tuxedo-backlight-control

1 file changed

+12
-7
lines changed

src/usr/share/tuxedo-backlight-control/ui.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ def __init__(self, parent):
2828
self.regions = (
2929
'color_left',
3030
'color_center',
31-
'color_right',
32-
'color_extra'
31+
'color_right'
3332
)
33+
if backlight.color_extra:
34+
self.regions.append('color_extra')
3435

3536
self.bg_frame = ttk.Frame(self.parent)
3637
self.bg_frame.grid(sticky=tk.NSEW, column=0, row=0)
@@ -65,8 +66,9 @@ def __init__(self, parent):
6566
'color_left': tk.StringVar(self, value=backlight.color_left.capitalize()),
6667
'color_center': tk.StringVar(self, value=backlight.color_center.capitalize()),
6768
'color_right': tk.StringVar(self, value=backlight.color_right.capitalize()),
68-
'color_extra': tk.StringVar(self, value=backlight.color_extra.capitalize())
6969
}
70+
if backlight.color_extra:
71+
self.values.color_extra = tk.StringVar(self, value=backlight.color_extra.capitalize())
7072

7173
def set_single_color(color):
7274
if not color == 'Select...':
@@ -108,15 +110,16 @@ def set_single_color(color):
108110
backlight.color_right.capitalize(),
109111
*backlight.display_colors(),
110112
command=self.color_setter('right')
111-
),
112-
'color_extra': ttk.OptionMenu(
113+
)
114+
}
115+
if backlight.color_extra:
116+
self.widgets.color_extra: ttk.OptionMenu(
113117
self.bg_frame,
114118
self.values['color_extra'],
115119
backlight.color_extra.capitalize(),
116120
*backlight.display_colors(),
117121
command=self.color_setter('extra')
118122
)
119-
}
120123

121124
def cmd():
122125
self.on_color_mode_switch(self.values['color_mode'].get())
@@ -151,7 +154,9 @@ def cmd():
151154
self.widgets['color_left']['menu'].config(**menuconfig)
152155
self.widgets['color_center']['menu'].config(**menuconfig)
153156
self.widgets['color_right']['menu'].config(**menuconfig)
154-
self.widgets['color_extra']['menu'].config(**menuconfig)
157+
158+
if backlight.color_extra:
159+
self.widgets['color_extra']['menu'].config(**menuconfig)
155160

156161
self.labels['mode'].grid(column=0, row=0, sticky='EW')
157162
self.widgets['mode'].grid(column=1, row=0, sticky='EW', padx=10)

0 commit comments

Comments
 (0)