From 3188a8232cdd5512b1baad0a4c31cdf9e6364206 Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Mon, 18 Mar 2024 14:58:16 +1100 Subject: [PATCH] make gui log messages pane disappear when no messages, and messages clear when updated --- countess/gui/logger.py | 11 +++++++++++ countess/gui/main.py | 3 ++- countess/gui/tree.py | 1 - countess/gui/unicode.py | 1 - 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/countess/gui/logger.py b/countess/gui/logger.py index 2243e6e..8c26e3b 100644 --- a/countess/gui/logger.py +++ b/countess/gui/logger.py @@ -12,6 +12,9 @@ def __init__(self, tk_parent, *a, **k): self.heading(0, text="name") self.heading(1, text="message") + def clear(self): + self.delete(*self.get_children()) + class LabeledProgressbar(ttk.Progressbar): """A progress bar with a label on top of it, the progress bar value can be set in the @@ -118,6 +121,14 @@ def remove_pbar(self, message): self.progress_bars[message].destroy() del self.progress_bars[message] + def clear(self): + self.logger.clear() + self.treeview.clear() + self.count = 0 + self.details = {} + for message in self.progress_bars: + self.remove_pbar(message) + class TreeviewDetailWindow(tk.Toplevel): def __init__(self, detail, *a, **k): diff --git a/countess/gui/main.py b/countess/gui/main.py index 470b110..473a7b9 100644 --- a/countess/gui/main.py +++ b/countess/gui/main.py @@ -92,7 +92,6 @@ def show_config_subframe(self): self.config_scrollbar.grid(row=3, column=1, sticky=tk.NS) self.logger_subframe = LoggerFrame(self.frame) - self.logger_subframe.grid(row=5, columnspan=2, sticky=tk.NSEW) self.logger = self.logger_subframe.get_logger(self.node.name) if self.node.plugin: @@ -204,6 +203,8 @@ def config_change_task_callback(self): self.node_update_thread = threading.Thread(target=self.node.prerun, args=(self.logger,)) self.node_update_thread.start() + self.logger_subframe.clear() + self.logger_subframe.grid(row=5, columnspan=2, sticky=tk.NSEW) self.logger_subframe.after(100, self.config_change_task_callback_2) self.change_callback(self.node) diff --git a/countess/gui/tree.py b/countess/gui/tree.py index f8ab23b..5705f0e 100644 --- a/countess/gui/tree.py +++ b/countess/gui/tree.py @@ -13,7 +13,6 @@ from functools import partial from countess.core.pipeline import PipelineNode -from countess.gui.unicode import UNICODE_INFO def _limit(value, min_value, max_value): diff --git a/countess/gui/unicode.py b/countess/gui/unicode.py index e2a4218..372ce21 100644 --- a/countess/gui/unicode.py +++ b/countess/gui/unicode.py @@ -15,4 +15,3 @@ UNICODE_CROSS = "\u2715" UNICODE_PLUS = "\u2795" UNICODE_INFO = "\u2139" -