changes and improvements
This commit is contained in:
26
fold.py
Normal file
26
fold.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# workers.py
|
||||
import flares
|
||||
|
||||
# This function must be completely standalone.
|
||||
# No PyQt imports here!
|
||||
def run_fold_process(haemo_obj, label, shared_dict):
|
||||
"""
|
||||
Runs in a separate OS process.
|
||||
Writes progress to shared_dict so the GUI can see it.
|
||||
"""
|
||||
try:
|
||||
def progress_callback(value):
|
||||
# Only update shared memory if the value has changed
|
||||
# This significantly reduces "noise" on the GUI thread
|
||||
if shared_dict.get(label) != value:
|
||||
shared_dict[label] = value
|
||||
|
||||
# Run the heavy calculation
|
||||
# Ensure 'flares' logic does not try to open any plots/GUIs itself!
|
||||
figures = flares.fold_channels(haemo_obj, progress_callback=progress_callback)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
# If something breaks here, we return the error string
|
||||
# so the main thread knows what happened.
|
||||
return f"ERROR: {str(e)}"
|
||||
Reference in New Issue
Block a user