From c3b367c5298b9f2346f21ddc2820d660231ede63 Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Fri, 8 Sep 2023 11:16:15 +1000 Subject: [PATCH] Do live updates in another thread to prevent UI interruption --- countess/gui/main.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/countess/gui/main.py b/countess/gui/main.py index 101167a..081623f 100644 --- a/countess/gui/main.py +++ b/countess/gui/main.py @@ -1,10 +1,10 @@ import re import sys +import threading import tkinter as tk import webbrowser from tkinter import filedialog, messagebox, ttk from typing import Optional -import threading from countess import VERSION from countess.core.config import export_config_graphviz, read_config, write_config @@ -55,6 +55,7 @@ class ConfiguratorWrapper: preview_subframe = None config_change_task = None notes_widget = None + node_update_thread = None def __init__(self, frame, node, change_callback): self.frame = frame @@ -191,10 +192,7 @@ def config_change_callback(self, *_): def config_change_task_callback(self): self.config_change_task = None - self.node_update_thread = threading.Thread( - target = self.node.prerun, - args=(self.logger,) - ) + self.node_update_thread = threading.Thread(target=self.node.prerun, args=(self.logger,)) self.node_update_thread.start() self.logger_subframe.after(100, self.config_change_task_callback_2) @@ -207,6 +205,7 @@ def config_change_task_callback_2(self): self.logger_subframe.after(100, self.config_change_task_callback_2) return + self.node_update_thread.join() # XXX stop the form scrolling away when it is refreshed, by putting # it back where it belongs.