Update menu.py

check for vban config, if none disable menu
This commit is contained in:
onyx-and-iris 2022-04-12 01:25:46 +01:00
parent 25d7ac1832
commit 335bb2b1db

View File

@ -15,6 +15,7 @@ class Menus(tk.Menu):
super().__init__() super().__init__()
self._parent = parent self._parent = parent
self._vmr = vmr self._vmr = vmr
if self.configuration_vban is not None:
self.vban_conns = [None for i, _ in enumerate(self.configuration_vban)] self.vban_conns = [None for i, _ in enumerate(self.configuration_vban)]
self.menubar = tk.Menu(self, tearoff=0) self.menubar = tk.Menu(self, tearoff=0)
parent["menu"] = self.menubar parent["menu"] = self.menubar
@ -88,6 +89,7 @@ class Menus(tk.Menu):
# vban connect menu # vban connect menu
self.menu_vban = tk.Menu(self.menubar, tearoff=0) self.menu_vban = tk.Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(menu=self.menu_vban, label="VBAN Connect") self.menubar.add_cascade(menu=self.menu_vban, label="VBAN Connect")
if self.configuration_vban is not None:
for i, _ in enumerate(self.configuration_vban): for i, _ in enumerate(self.configuration_vban):
setattr(self, f"menu_vban_{i+1}", tk.Menu(self.menu_vban, tearoff=0)) setattr(self, f"menu_vban_{i+1}", tk.Menu(self.menu_vban, tearoff=0))
target_menu = getattr(self, f"menu_vban_{i+1}") target_menu = getattr(self, f"menu_vban_{i+1}")
@ -101,6 +103,8 @@ class Menus(tk.Menu):
label="Disconnect", command=partial(self.vban_disconnect, i) label="Disconnect", command=partial(self.vban_disconnect, i)
) )
target_menu.entryconfig(1, state="disabled") target_menu.entryconfig(1, state="disabled")
else:
self.menubar.entryconfig(2, state="disabled")
# extends menu # extends menu
self.menu_extends = tk.Menu(self.menubar, tearoff=0) self.menu_extends = tk.Menu(self.menubar, tearoff=0)
@ -191,6 +195,7 @@ class Menus(tk.Menu):
@property @property
def configuration_vban(self): def configuration_vban(self):
if "vban" in configuration:
return configuration["vban"] return configuration["vban"]
def action_invoke_voicemeeter(self, cmd): def action_invoke_voicemeeter(self, cmd):