updates to bus mode cache

add a separate bus mode cache for each interface.

add property objects to config frame for setting/getting from bus mode cache.

update function update_bus_modes to fit changes to bus mode cache
This commit is contained in:
onyx-and-iris 2022-04-26 20:59:00 +01:00
parent 4fb7a88855
commit 80340ac219
3 changed files with 31 additions and 19 deletions

View File

@ -64,7 +64,10 @@ class App(tk.Tk):
] ]
_base_vals.submixes = self.configuration["submixes"]["default"] _base_vals.submixes = self.configuration["submixes"]["default"]
_base_vals.mwscroll_step = self.configuration["mwscroll_step"]["size"] _base_vals.mwscroll_step = self.configuration["mwscroll_step"]["size"]
self.bus_modes = [tk.StringVar(value="normal") for _ in range(12)] self.bus_modes_cache = {
"vmr": list(tk.StringVar(value="normal") for _ in range(12)),
"vban": list(tk.StringVar(value="normal") for _ in range(12)),
}
# create menus # create menus
self.menus = Menus(self, vmr) self.menus = Menus(self, vmr)

View File

@ -394,9 +394,9 @@ class ChannelFrame(ttk.Frame):
def update_bus_modes(self): def update_bus_modes(self):
[ [
self._parent.bus_modes[i].set( self._parent.bus_modes_cache[
labelframe.config_frame.bus_mode_current.get() "vban" if _base_vals.vban_connected else "vmr"
) ][i].set(labelframe.config_frame.bus_mode)
for i, labelframe in enumerate(self.labelframes) for i, labelframe in enumerate(self.labelframes)
if labelframe is not None and labelframe.config_frame if labelframe is not None and labelframe.config_frame
] ]

View File

@ -378,35 +378,44 @@ class BusConfig(Config):
_target = super(BusConfig, self).target _target = super(BusConfig, self).target
return getattr(_target, self.identifier)[self.index] return getattr(_target, self.identifier)[self.index]
@property
def bus_mode(self):
return self._parent.bus_modes_cache[
"vban" if _base_vals.vban_connected else "vmr"
][self.index].get()
@bus_mode.setter
def bus_mode(self, val):
self._parent.bus_modes_cache["vban" if _base_vals.vban_connected else "vmr"][
self.index
].set(val)
def make_row0(self): def make_row0(self):
self.bus_mode_label_text = tk.StringVar() self.bus_mode_label_text = tk.StringVar()
self.bus_mode_current = tk.StringVar( self.bus_mode_label_text.set(f"Bus Mode: {self.bus_mode}")
value=self._parent.bus_modes[self.index].get() setattr(self.target.mode, self.bus_mode.lower(), True)
)
self.bus_mode_label_text.set(f"Bus Mode: {self.bus_mode_current.get()}")
setattr(self.target.mode, self.bus_mode_current.get(), True)
self.busmode_button = ttk.Button(self, textvariable=self.bus_mode_label_text) self.busmode_button = ttk.Button(self, textvariable=self.bus_mode_label_text)
self.busmode_button.grid(column=0, row=0, columnspan=2, sticky=(tk.W)) self.busmode_button.grid(column=0, row=0, columnspan=2, sticky=(tk.W))
self.busmode_button.bind("<Button-1>", self.rotate_bus_modes_right) self.busmode_button.bind("<Button-1>", self.rotate_bus_modes_right)
self.busmode_button.bind("<Button-3>", self.rotate_bus_modes_left) self.busmode_button.bind("<Button-3>", self.rotate_bus_modes_left)
def rotate_bus_modes_right(self, *args): def rotate_bus_modes_right(self, *args):
current_index = self.bus_modes.index(self.bus_mode_current.get()) current_index = self.bus_modes.index(self.bus_mode)
if current_index + 1 < len(self.bus_modes): if current_index + 1 < len(self.bus_modes):
self.bus_mode_current.set(self.bus_modes[current_index + 1]) self.bus_mode = self.bus_modes[current_index + 1]
else: else:
self.bus_mode_current.set(self.bus_modes[0]) self.bus_mode = self.bus_modes[0]
setattr(self.target.mode, self.bus_mode_current.get().lower(), True) setattr(self.target.mode, self.bus_mode.lower(), True)
self.bus_mode_label_text.set(f"Bus Mode: {self.bus_mode_current.get()}") self.bus_mode_label_text.set(f"Bus Mode: {self.bus_mode}")
def rotate_bus_modes_left(self, *args): def rotate_bus_modes_left(self, *args):
current_index = self.bus_modes.index(self.bus_mode_current.get()) current_index = self.bus_modes.index(self.bus_mode)
if current_index == 0: if current_index == 0:
self.bus_mode_current.set(self.bus_modes[-1]) self.bus_mode = self.bus_modes[-1]
else: else:
self.bus_mode_current.set(self.bus_modes[current_index - 1]) self.bus_mode = self.bus_modes[current_index - 1]
setattr(self.target.mode, self.bus_mode_current.get().lower(), True) setattr(self.target.mode, self.bus_mode.lower(), True)
self.bus_mode_label_text.set(f"Bus Mode: {self.bus_mode_current.get()}") self.bus_mode_label_text.set(f"Bus Mode: {self.bus_mode}")
def make_row1(self): def make_row1(self):
param_buttons = [ param_buttons = [