@@ -27,7 +27,7 @@ if os.name == 'nt':
2727
2828from lifx_control_panel import HEARTBEAT_RATE_MS , FRAME_PERIOD_MS , LOGFILE
2929from lifx_control_panel ._constants import BUILD_DATE , AUTHOR , DEBUGGING , VERSION
30- from lifx_control_panel .frames import LightFrame , MultiZoneFrame , GroupFrame
30+ from lifx_control_panel .frames import LightFrame , GroupFrame
3131from lifx_control_panel .ui import settings
3232from lifx_control_panel .ui .icon_list import BulbIconList
3333from lifx_control_panel .ui .settings import config
@@ -116,23 +116,16 @@ class LifxFrame(ttk.Frame): # pylint: disable=too-many-ancestors
116116 self .group_icons .canvas .bind ('<Button-1>' , self .on_bulb_canvas_click )
117117
118118 # Setup tray icon
119- def lambda_quit (self_ ):
120- """ Build an anonymous function call w/ correct 'self' scope"""
121- return lambda * _ , ** __ : self_ .on_closing ()
122-
123- def lambda_adjust (self_ ):
124- return lambda * _ , ** __ : self_ .master .deiconify ()
125-
126119 def run_tray_icon ():
127120 """ Allow SysTrayIcon in a separate thread """
128121 image = Image .open (resource_path ('res/icon_vector.ico' ))
129122
130123 icon = pystray .Icon ("LIFX Control Panel" , image , menu = pystray .Menu (
131124 pystray .MenuItem ('Open' ,
132- lambda_adjust ( self ),
125+ lambda * _ , ** __ : self . master . deiconify ( ),
133126 default = True ),
134127 pystray .MenuItem ('Quit' ,
135- lambda_quit ( self )),
128+ lambda * _ , ** __ : self . on_closing ( )),
136129 ))
137130 icon .run ()
138131
@@ -165,8 +158,6 @@ class LifxFrame(ttk.Frame): # pylint: disable=too-many-ancestors
165158 if not stop_event .is_set ():
166159 stop_event .set ()
167160 device_list : List [Union [lifxlan .Group , lifxlan .Light , lifxlan .MultiZoneLight ]] = self .lifx .get_devices ()
168- if self .bulb_interface :
169- del self .bulb_interface
170161 self .bulb_interface = AsyncBulbInterface (stop_event , HEARTBEAT_RATE_MS )
171162 self .bulb_interface .set_device_list (device_list )
172163 self .bulb_interface .daemon = True
@@ -184,10 +175,8 @@ class LifxFrame(ttk.Frame): # pylint: disable=too-many-ancestors
184175 if label not in self .bulb_icons .bulb_dict :
185176 self .bulb_icons .draw_bulb_icon (light , label )
186177 if label not in self .frame_map :
187- if light .supports_multizone ():
188- self .frame_map [label ] = MultiZoneFrame (self , light )
189- else :
190- self .frame_map [label ] = LightFrame (self , light )
178+ # LightFrame._get_light_info already handles multizone devices
179+ self .frame_map [label ] = LightFrame (self , light )
191180 self .current_lightframe = self .frame_map [label ]
192181 try :
193182 self .bulb_icons .set_selected_bulb (label )
@@ -260,13 +249,9 @@ class LifxFrame(ttk.Frame): # pylint: disable=too-many-ancestors
260249
261250 def save_keybind (self , light , keypress , color ):
262251 """ Builds a new anonymous function changing light to color when keypress is entered. """
263-
264- def lambda_factory (self , light , color ):
265- """ https://stackoverflow.com/questions/938429/scope-of-lambda-functions-and-their-parameters """
266- return lambda * _ , ** __ : self .device_map [light ].set_color (color ,
267- duration = float (config ["AverageColor" ]["duration" ]))
268-
269- func = lambda_factory (self , light , color )
252+ # default args bind light/color now, not at call time
253+ func = lambda * _ , light = light , color = color , ** __ : self .device_map [light ].set_color (
254+ color , duration = float (config ["AverageColor" ]["duration" ]))
270255 self .key_listener .register_function (keypress , func )
271256
272257 def delete_keybind (self , keycombo ):
0 commit comments