Skip to content

Commit

Permalink
Do live updates in another thread to prevent UI interruption
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzoic committed Sep 8, 2023
1 parent d88b525 commit c3b367c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions countess/gui/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down

0 comments on commit c3b367c

Please sign in to comment.