refactor ldirty, add reinitialize level arrays in _make_app

refactor set ldirty.

reinitialize level arrays in _make_app (when switching between local,network connection)
This commit is contained in:
onyx-and-iris 2022-04-17 09:27:27 +01:00
parent cd4264be8b
commit da9e538cc7
2 changed files with 14 additions and 6 deletions

View File

@ -65,7 +65,7 @@ class App(tk.Tk):
self.styletable = ttk.Style()
self._vmr = vmr
# start pdirty watcher
# start watchers, initialize level arrays
self.upd_pdirty()
self.strip_levels = self.target.strip_levels
self.bus_levels = self.target.bus_levels
@ -135,6 +135,8 @@ class App(tk.Tk):
)
self._vban = vban
self.kind = kind
self.strip_levels = self.target.strip_levels
self.bus_levels = self.target.bus_levels
self._make_top_level_frames()
@ -184,7 +186,7 @@ class App(tk.Tk):
self.comp_strip = [not a == b for a, b in zip(self.strip_levels, _strip_levels)]
self.comp_bus = [not a == b for a, b in zip(self.bus_levels, _bus_levels)]
self.ldirty = any(self.comp_strip) or any(self.comp_bus)
self.ldirty = any(any(l) for l in (self.comp_strip, self.comp_bus))
if self.ldirty:
self.strip_levels = _strip_levels
self.bus_levels = _bus_levels

View File

@ -346,15 +346,15 @@ class ChannelFrame(ttk.Frame):
# create labelframes
if is_strip:
self.strips = [
self.strips = tuple(
Strip(self, i, self.identifier)
for i in range(self.phys_in + self.virt_in)
]
)
else:
self.buses = [
self.buses = tuple(
Bus(self, i, self.identifier)
for i in range(self.phys_out + self.virt_out)
]
)
# position label frames. destroy any without label text
self.labelframes = self.strips if is_strip else self.buses
@ -367,6 +367,12 @@ class ChannelFrame(ttk.Frame):
self.columnconfigure(i, minsize=0)
labelframe.grid_remove()
for i, labelframe in enumerate(self.labelframes):
labelframe.grid(row=0, column=i)
if not labelframe.cget("text"):
self.columnconfigure(i, minsize=0)
labelframe.grid_remove()
@property
def target(self):
"""returns the current interface"""