|
|
|
@ -33,10 +33,28 @@ class Hui(wx.Frame):
|
|
|
|
|
self.pnl.SetSizer(self.sizer)
|
|
|
|
|
self.add_bridges()
|
|
|
|
|
|
|
|
|
|
def redraw(*args):
|
|
|
|
|
"""Decorator used for redrawing the widgets in the sizer
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
function: The decorated function
|
|
|
|
|
"""
|
|
|
|
|
func = args[0]
|
|
|
|
|
|
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
|
"""The wrapper function for the decorator
|
|
|
|
|
"""
|
|
|
|
|
self = args[0]
|
|
|
|
|
self.sizer.Clear(delete_windows=True)
|
|
|
|
|
func(*args, **kwargs)
|
|
|
|
|
self.sizer.Layout()
|
|
|
|
|
|
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
@redraw
|
|
|
|
|
def add_bridges(self):
|
|
|
|
|
"""Add bridges to sizer, the entry point of the program
|
|
|
|
|
"""
|
|
|
|
|
self.sizer.Clear(delete_windows=True)
|
|
|
|
|
if self.m_bridges:
|
|
|
|
|
for bridge in self.m_bridges:
|
|
|
|
|
btn: wx.Button = wx.Button(self.pnl, label=str(bridge))
|
|
|
|
@ -48,15 +66,14 @@ class Hui(wx.Frame):
|
|
|
|
|
self.sizer.Add(btn, 0, wx.EXPAND)
|
|
|
|
|
self.Bind(wx.EVT_BUTTON,
|
|
|
|
|
lambda event: self.discover_new_bridges(), btn)
|
|
|
|
|
self.sizer.Layout()
|
|
|
|
|
|
|
|
|
|
@redraw
|
|
|
|
|
def add_groups(self, groups: list[HueGroup]):
|
|
|
|
|
"""This will add the groups to the sizer, when coming down from a bridge, or up from a light
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
groups (list[HueGroup]): The groups to display
|
|
|
|
|
"""
|
|
|
|
|
self.sizer.Clear(delete_windows=True)
|
|
|
|
|
bridge_btn: wx.Button = wx.Button(self.pnl, label=str(self.cur_bridge))
|
|
|
|
|
self.sizer.Add(bridge_btn, 0, wx.EXPAND)
|
|
|
|
|
self.Bind(wx.EVT_BUTTON,
|
|
|
|
@ -77,16 +94,14 @@ class Hui(wx.Frame):
|
|
|
|
|
self.Bind(wx.EVT_BUTTON,
|
|
|
|
|
lambda event, mgroupid=groupid: self.goto_group(mgroupid), group_btn)
|
|
|
|
|
self.sizer.Add(inner_sizer, 0, wx.EXPAND)
|
|
|
|
|
self.sizer.Layout()
|
|
|
|
|
|
|
|
|
|
# noinspection PyDefaultArgument
|
|
|
|
|
@redraw
|
|
|
|
|
def add_lights(self, lights: list[HueLight]):
|
|
|
|
|
"""This will add the lights from a group to the sizer
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
lights (list[HueLight]): The lights to display
|
|
|
|
|
"""
|
|
|
|
|
self.sizer.Clear(delete_windows=True)
|
|
|
|
|
group_btn: wx.Button = wx.Button(self.pnl, label=str(self.cur_group))
|
|
|
|
|
self.sizer.Add(group_btn, 0, wx.EXPAND)
|
|
|
|
|
self.Bind(wx.EVT_BUTTON,
|
|
|
|
@ -109,7 +124,6 @@ class Hui(wx.Frame):
|
|
|
|
|
self.Bind(wx.EVT_BUTTON,
|
|
|
|
|
lambda event, mlightid=lightid: self.goto_light(mlightid), light_btn)
|
|
|
|
|
self.sizer.Add(inner_sizer, 0, wx.EXPAND)
|
|
|
|
|
self.sizer.Layout()
|
|
|
|
|
|
|
|
|
|
def goto_bridge(self, bridge: HueBridge):
|
|
|
|
|
"""Call back for a bridge button
|
|
|
|
@ -159,6 +173,7 @@ class Hui(wx.Frame):
|
|
|
|
|
self.cur_bridge.get_light_by_id(lightid).toggle()
|
|
|
|
|
self.add_lights(lights)
|
|
|
|
|
|
|
|
|
|
@redraw
|
|
|
|
|
def goto_light(self, lightid: int):
|
|
|
|
|
"""Call back for light button
|
|
|
|
|
|
|
|
|
@ -167,7 +182,6 @@ class Hui(wx.Frame):
|
|
|
|
|
"""
|
|
|
|
|
light: HueLight = self.cur_bridge.get_light_by_id(lightid)
|
|
|
|
|
is_on: bool = light.is_on()
|
|
|
|
|
self.sizer.Clear(delete_windows=True)
|
|
|
|
|
group: HueGroup = self.cur_group
|
|
|
|
|
group_btn: wx.Button = wx.Button(self.pnl, label=str(group))
|
|
|
|
|
self.sizer.Add(group_btn, 0, wx.EXPAND)
|
|
|
|
@ -200,7 +214,6 @@ class Hui(wx.Frame):
|
|
|
|
|
self.sizer.Add(c_slider, 0, wx.EXPAND)
|
|
|
|
|
self.Bind(wx.EVT_SCROLL_THUMBRELEASE,
|
|
|
|
|
lambda event: self.set_colortemp(event, light.get_id()), c_slider)
|
|
|
|
|
self.sizer.Layout()
|
|
|
|
|
|
|
|
|
|
def set_brightness(self, event: wx.ScrollEvent, lightid: int):
|
|
|
|
|
"""Call back for brightness slider
|
|
|
|
|