From da9e538cc70f9d13a4f7111495822058645ae064 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sun, 17 Apr 2022 09:27:27 +0100 Subject: [PATCH] refactor ldirty, add reinitialize level arrays in _make_app refactor set ldirty. reinitialize level arrays in _make_app (when switching between local,network connection) --- vmcompact/app.py | 6 ++++-- vmcompact/channels.py | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/vmcompact/app.py b/vmcompact/app.py index d798b0a..f151201 100644 --- a/vmcompact/app.py +++ b/vmcompact/app.py @@ -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 diff --git a/vmcompact/channels.py b/vmcompact/channels.py index ade928a..afc9438 100644 --- a/vmcompact/channels.py +++ b/vmcompact/channels.py @@ -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"""