spacr 0.2.67__py3-none-any.whl → 0.2.81__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spacr/core.py +1 -1
- spacr/gui.py +35 -20
- spacr/gui_core.py +152 -105
- spacr/gui_elements.py +190 -18
- spacr/gui_utils.py +28 -17
- spacr/sequencing.py +234 -422
- spacr/settings.py +13 -9
- spacr/utils.py +4 -1
- {spacr-0.2.67.dist-info → spacr-0.2.81.dist-info}/METADATA +4 -1
- {spacr-0.2.67.dist-info → spacr-0.2.81.dist-info}/RECORD +14 -14
- {spacr-0.2.67.dist-info → spacr-0.2.81.dist-info}/LICENSE +0 -0
- {spacr-0.2.67.dist-info → spacr-0.2.81.dist-info}/WHEEL +0 -0
- {spacr-0.2.67.dist-info → spacr-0.2.81.dist-info}/entry_points.txt +0 -0
- {spacr-0.2.67.dist-info → spacr-0.2.81.dist-info}/top_level.txt +0 -0
spacr/core.py
CHANGED
@@ -1638,7 +1638,7 @@ def preprocess_generate_masks(src, settings={}):
|
|
1638
1638
|
|
1639
1639
|
settings = set_default_settings_preprocess_generate_masks(src, settings)
|
1640
1640
|
settings['src'] = src
|
1641
|
-
save_settings(settings)
|
1641
|
+
save_settings(settings, name='gen_mask')
|
1642
1642
|
|
1643
1643
|
if not settings['pathogen_channel'] is None:
|
1644
1644
|
custom_model_ls = ['toxo_pv_lumen','toxo_cyto']
|
spacr/gui.py
CHANGED
@@ -3,6 +3,7 @@ from tkinter import ttk
|
|
3
3
|
from multiprocessing import set_start_method
|
4
4
|
from .gui_elements import spacrButton, create_menu_bar, set_dark_style
|
5
5
|
from .gui_core import initiate_root
|
6
|
+
from screeninfo import get_monitors
|
6
7
|
|
7
8
|
class MainApp(tk.Tk):
|
8
9
|
def __init__(self, default_app=None):
|
@@ -12,12 +13,23 @@ class MainApp(tk.Tk):
|
|
12
13
|
self.geometry("100x100")
|
13
14
|
self.update_idletasks()
|
14
15
|
|
15
|
-
#
|
16
|
-
self.attributes('-fullscreen', True)
|
16
|
+
# Get the current window position
|
17
17
|
self.update_idletasks()
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
x = self.winfo_x()
|
19
|
+
y = self.winfo_y()
|
20
|
+
|
21
|
+
# Find the monitor where the window is located
|
22
|
+
for monitor in get_monitors():
|
23
|
+
if monitor.x <= x < monitor.x + monitor.width and monitor.y <= y < monitor.y + monitor.height:
|
24
|
+
width = monitor.width
|
25
|
+
height = monitor.height
|
26
|
+
break
|
27
|
+
else:
|
28
|
+
monitor = get_monitors()[0]
|
29
|
+
width = monitor.width
|
30
|
+
height = monitor.height
|
31
|
+
|
32
|
+
# Set the window size to the dimensions of the monitor where it is located
|
21
33
|
self.geometry(f"{width}x{height}")
|
22
34
|
self.title("SpaCr GUI Collection")
|
23
35
|
self.configure(bg='#333333') # Set window background to dark gray
|
@@ -36,7 +48,6 @@ class MainApp(tk.Tk):
|
|
36
48
|
}
|
37
49
|
|
38
50
|
self.additional_gui_apps = {
|
39
|
-
#"Sequencing": (lambda frame: initiate_root(self, 'sequencing'), "Analyze sequencing data."),
|
40
51
|
"Umap": (lambda frame: initiate_root(self, 'umap'), "Generate UMAP embeddings with datapoints represented as images."),
|
41
52
|
"Train Cellpose": (lambda frame: initiate_root(self, 'train_cellpose'), "Train custom Cellpose models."),
|
42
53
|
"ML Analyze": (lambda frame: initiate_root(self, 'ml_analyze'), "Machine learning analysis of data."),
|
@@ -58,32 +69,36 @@ class MainApp(tk.Tk):
|
|
58
69
|
def create_widgets(self):
|
59
70
|
create_menu_bar(self)
|
60
71
|
|
61
|
-
|
62
|
-
self.canvas.grid(row=0, column=0, sticky="nsew")
|
72
|
+
# Use a grid layout for centering
|
63
73
|
self.grid_rowconfigure(0, weight=1)
|
64
74
|
self.grid_columnconfigure(0, weight=1)
|
65
75
|
|
66
|
-
self.content_frame = tk.Frame(self
|
76
|
+
self.content_frame = tk.Frame(self)
|
67
77
|
self.content_frame.grid(row=0, column=0, sticky="nsew")
|
78
|
+
|
79
|
+
# Center the content frame within the window
|
80
|
+
self.content_frame.grid_rowconfigure(0, weight=1)
|
81
|
+
self.content_frame.grid_columnconfigure(0, weight=1)
|
68
82
|
|
69
|
-
self.
|
70
|
-
|
71
|
-
|
83
|
+
self.inner_frame = tk.Frame(self.content_frame)
|
84
|
+
self.inner_frame.grid(row=0, column=0)
|
85
|
+
|
86
|
+
set_dark_style(ttk.Style(), containers=[self.content_frame, self.inner_frame])
|
72
87
|
|
73
88
|
self.create_startup_screen()
|
74
89
|
|
75
90
|
def create_startup_screen(self):
|
76
|
-
self.clear_frame(self.
|
91
|
+
self.clear_frame(self.inner_frame)
|
77
92
|
|
78
|
-
main_buttons_frame = tk.Frame(self.
|
93
|
+
main_buttons_frame = tk.Frame(self.inner_frame)
|
79
94
|
main_buttons_frame.pack(pady=10)
|
80
95
|
set_dark_style(ttk.Style(), containers=[main_buttons_frame])
|
81
96
|
|
82
|
-
additional_buttons_frame = tk.Frame(self.
|
97
|
+
additional_buttons_frame = tk.Frame(self.inner_frame)
|
83
98
|
additional_buttons_frame.pack(pady=10)
|
84
99
|
set_dark_style(ttk.Style(), containers=[additional_buttons_frame])
|
85
100
|
|
86
|
-
description_frame = tk.Frame(self.
|
101
|
+
description_frame = tk.Frame(self.inner_frame, height=70)
|
87
102
|
description_frame.pack(fill=tk.X, pady=10)
|
88
103
|
description_frame.pack_propagate(False)
|
89
104
|
set_dark_style(ttk.Style(), containers=[description_frame])
|
@@ -93,7 +108,7 @@ class MainApp(tk.Tk):
|
|
93
108
|
|
94
109
|
logo_button = spacrButton(main_buttons_frame, text="SpaCr", command=lambda: self.load_app("logo_spacr", initiate_root), icon_name="logo_spacr", size=100, show_text=False)
|
95
110
|
logo_button.grid(row=0, column=0, padx=5, pady=5)
|
96
|
-
self.main_buttons[logo_button] = "SpaCr provides a flexible toolset to extract single-cell images and measurements from high-content cell painting experiments, train deep-learning models to classify cellular/subcellular phenotypes, simulate, and analyze pooled CRISPR-Cas9 imaging screens
|
111
|
+
self.main_buttons[logo_button] = "SpaCr provides a flexible toolset to extract single-cell images and measurements from high-content cell painting experiments, train deep-learning models to classify cellular/subcellular phenotypes, simulate, and analyze pooled CRISPR-Cas9 imaging screens."
|
97
112
|
|
98
113
|
for i, (app_name, app_data) in enumerate(self.main_gui_apps.items()):
|
99
114
|
app_func, app_desc = app_data
|
@@ -127,9 +142,9 @@ class MainApp(tk.Tk):
|
|
127
142
|
self.description_label.update_idletasks()
|
128
143
|
|
129
144
|
def load_app(self, app_name, app_func):
|
130
|
-
self.clear_frame(self.
|
145
|
+
self.clear_frame(self.inner_frame)
|
131
146
|
|
132
|
-
app_frame = tk.Frame(self.
|
147
|
+
app_frame = tk.Frame(self.inner_frame)
|
133
148
|
app_frame.pack(fill=tk.BOTH, expand=True)
|
134
149
|
set_dark_style(ttk.Style(), containers=[app_frame])
|
135
150
|
app_func(app_frame)
|
@@ -144,4 +159,4 @@ def gui_app():
|
|
144
159
|
|
145
160
|
if __name__ == "__main__":
|
146
161
|
set_start_method('spawn', force=True)
|
147
|
-
gui_app()
|
162
|
+
gui_app()
|
spacr/gui_core.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import traceback, ctypes, csv, re
|
1
|
+
import traceback, ctypes, csv, re, platform, time
|
2
2
|
import tkinter as tk
|
3
3
|
from tkinter import ttk
|
4
4
|
from tkinter import filedialog
|
@@ -19,7 +19,7 @@ try:
|
|
19
19
|
except AttributeError:
|
20
20
|
pass
|
21
21
|
|
22
|
-
from .gui_elements import spacrProgressBar, spacrButton, spacrLabel, spacrFrame, spacrDropdownMenu , set_dark_style
|
22
|
+
from .gui_elements import spacrProgressBar, spacrButton, spacrLabel, spacrFrame, spacrDropdownMenu , spacrSlider, set_dark_style, standardize_figure
|
23
23
|
|
24
24
|
# Define global variables
|
25
25
|
q = None
|
@@ -35,8 +35,6 @@ figures = None
|
|
35
35
|
figure_index = None
|
36
36
|
progress_bar = None
|
37
37
|
usage_bars = None
|
38
|
-
fig_memory_limit = None
|
39
|
-
figure_current_memory_usage = None
|
40
38
|
|
41
39
|
thread_control = {"run_thread": None, "stop_requested": False}
|
42
40
|
|
@@ -80,35 +78,10 @@ def toggle_settings(button_scrollable_frame):
|
|
80
78
|
category_dropdown.grid(row=0, column=4, sticky="ew", pady=2, padx=2)
|
81
79
|
vars_dict = hide_all_settings(vars_dict, categories)
|
82
80
|
|
83
|
-
def process_fig_queue():
|
84
|
-
global canvas, fig_queue, canvas_widget, parent_frame, uppdate_frequency, figures, figure_index
|
85
|
-
|
86
|
-
from .gui_elements import standardize_figure
|
87
|
-
try:
|
88
|
-
while not fig_queue.empty():
|
89
|
-
fig = fig_queue.get_nowait()
|
90
|
-
|
91
|
-
if fig is None:
|
92
|
-
print("Warning: Retrieved a None figure from fig_queue.")
|
93
|
-
continue # Skip processing if the figure is None
|
94
|
-
|
95
|
-
# Standardize the figure appearance before adding it to the list
|
96
|
-
standardize_figure(fig)
|
97
|
-
|
98
|
-
figures.append(fig)
|
99
|
-
if figure_index == len(figures) - 2:
|
100
|
-
figure_index += 1
|
101
|
-
display_figure(fig)
|
102
|
-
except Exception as e:
|
103
|
-
traceback.print_exc()
|
104
|
-
finally:
|
105
|
-
after_id = canvas_widget.after(uppdate_frequency, process_fig_queue)
|
106
|
-
parent_frame.after_tasks.append(after_id)
|
107
|
-
|
108
81
|
def display_figure(fig):
|
109
82
|
global canvas, canvas_widget
|
110
83
|
|
111
|
-
from .gui_elements import
|
84
|
+
from .gui_elements import save_figure_as_format, modify_figure
|
112
85
|
|
113
86
|
# Apply the dark style to the context menu
|
114
87
|
style_out = set_dark_style(ttk.Style())
|
@@ -197,7 +170,7 @@ def display_figure(fig):
|
|
197
170
|
#flash_feedback("right")
|
198
171
|
show_next_figure()
|
199
172
|
|
200
|
-
def
|
173
|
+
def zoom_v1(event):
|
201
174
|
nonlocal scale_factor
|
202
175
|
|
203
176
|
zoom_speed = 0.1 # Adjust the zoom speed for smoother experience
|
@@ -230,16 +203,55 @@ def display_figure(fig):
|
|
230
203
|
# Redraw the figure
|
231
204
|
fig.canvas.draw_idle()
|
232
205
|
|
206
|
+
def zoom(event):
|
207
|
+
nonlocal scale_factor
|
208
|
+
|
209
|
+
zoom_speed = 0.1 # Adjust the zoom speed for smoother experience
|
210
|
+
|
211
|
+
# Determine the zoom direction based on the scroll event
|
212
|
+
if event.num == 4 or event.delta > 0: # Scroll up (zoom in)
|
213
|
+
scale_factor /= (1 + zoom_speed) # Divide to zoom in
|
214
|
+
elif event.num == 5 or event.delta < 0: # Scroll down (zoom out)
|
215
|
+
scale_factor *= (1 + zoom_speed) # Multiply to zoom out
|
216
|
+
|
217
|
+
# Adjust the axes limits based on the new scale factor
|
218
|
+
for ax in canvas.figure.get_axes():
|
219
|
+
xlim = ax.get_xlim()
|
220
|
+
ylim = ax.get_ylim()
|
221
|
+
|
222
|
+
x_center = (xlim[1] + xlim[0]) / 2
|
223
|
+
y_center = (ylim[1] + ylim[0]) / 2
|
224
|
+
|
225
|
+
x_range = (xlim[1] - xlim[0]) * scale_factor
|
226
|
+
y_range = (ylim[1] - ylim[0]) * scale_factor
|
227
|
+
|
228
|
+
# Set the new limits
|
229
|
+
ax.set_xlim([x_center - x_range / 2, x_center + x_range / 2])
|
230
|
+
ax.set_ylim([y_center - y_range / 2, y_center + y_range / 2])
|
231
|
+
|
232
|
+
# Redraw the figure efficiently
|
233
|
+
canvas.draw_idle()
|
234
|
+
|
235
|
+
|
233
236
|
# Bind events for hover, click interactions, and zoom
|
234
237
|
canvas_widget.bind("<Motion>", on_hover)
|
235
238
|
canvas_widget.bind("<Leave>", on_leave)
|
236
239
|
canvas_widget.bind("<Button-1>", on_click)
|
237
240
|
canvas_widget.bind("<Button-3>", on_right_click)
|
238
241
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
242
|
+
|
243
|
+
# Detect the operating system and bind the appropriate mouse wheel events
|
244
|
+
current_os = platform.system()
|
245
|
+
|
246
|
+
if current_os == "Windows":
|
247
|
+
canvas_widget.bind("<MouseWheel>", zoom) # Windows
|
248
|
+
elif current_os == "Darwin": # macOS
|
249
|
+
canvas_widget.bind("<MouseWheel>", zoom)
|
250
|
+
canvas_widget.bind("<Button-4>", zoom) # Scroll up
|
251
|
+
canvas_widget.bind("<Button-5>", zoom) # Scroll down
|
252
|
+
elif current_os == "Linux":
|
253
|
+
canvas_widget.bind("<Button-4>", zoom) # Linux Scroll up
|
254
|
+
canvas_widget.bind("<Button-5>", zoom) # Linux Scroll down
|
243
255
|
|
244
256
|
def clear_unused_figures():
|
245
257
|
global figures, figure_index
|
@@ -253,6 +265,7 @@ def clear_unused_figures():
|
|
253
265
|
|
254
266
|
def show_previous_figure():
|
255
267
|
global figure_index, figures, fig_queue
|
268
|
+
|
256
269
|
if figure_index is not None and figure_index > 0:
|
257
270
|
figure_index -= 1
|
258
271
|
display_figure(figures[figure_index])
|
@@ -270,8 +283,104 @@ def show_next_figure():
|
|
270
283
|
figure_index += 1
|
271
284
|
display_figure(fig)
|
272
285
|
|
273
|
-
def
|
274
|
-
global
|
286
|
+
def process_fig_queue():
|
287
|
+
global canvas, fig_queue, canvas_widget, parent_frame, uppdate_frequency, figures, figure_index, index_control
|
288
|
+
|
289
|
+
from .gui_elements import standardize_figure
|
290
|
+
try:
|
291
|
+
while not fig_queue.empty():
|
292
|
+
fig = fig_queue.get_nowait()
|
293
|
+
|
294
|
+
if fig is None:
|
295
|
+
print("Warning: Retrieved a None figure from fig_queue.")
|
296
|
+
continue # Skip processing if the figure is None
|
297
|
+
|
298
|
+
# Standardize the figure appearance before adding it to the list
|
299
|
+
fig = standardize_figure(fig)
|
300
|
+
|
301
|
+
figures.append(fig)
|
302
|
+
|
303
|
+
# Update the slider range and set the value to the latest figure index
|
304
|
+
index_control.set_to(len(figures) - 1)
|
305
|
+
|
306
|
+
if figure_index == -1:
|
307
|
+
figure_index += 1
|
308
|
+
display_figure(figures[figure_index])
|
309
|
+
index_control.set(figure_index)
|
310
|
+
|
311
|
+
except Exception as e:
|
312
|
+
traceback.print_exc()
|
313
|
+
finally:
|
314
|
+
after_id = canvas_widget.after(uppdate_frequency, process_fig_queue)
|
315
|
+
parent_frame.after_tasks.append(after_id)
|
316
|
+
|
317
|
+
def update_figure(value):
|
318
|
+
global figure_index, figures
|
319
|
+
|
320
|
+
# Convert the value to an integer
|
321
|
+
index = int(value)
|
322
|
+
|
323
|
+
# Check if the index is valid
|
324
|
+
if 0 <= index < len(figures):
|
325
|
+
figure_index = index
|
326
|
+
display_figure(figures[figure_index])
|
327
|
+
|
328
|
+
# Update the index control widget's range and value
|
329
|
+
index_control.set_to(len(figures) - 1)
|
330
|
+
index_control.set(figure_index)
|
331
|
+
|
332
|
+
def setup_plot_section(vertical_container):
|
333
|
+
global canvas, canvas_widget, figures, figure_index, index_control
|
334
|
+
|
335
|
+
# Initialize deque for storing figures and the current index
|
336
|
+
figures = deque()
|
337
|
+
|
338
|
+
# Create a frame for the plot section
|
339
|
+
plot_frame = tk.Frame(vertical_container)
|
340
|
+
vertical_container.add(plot_frame, stretch="always")
|
341
|
+
|
342
|
+
# Set up the plot
|
343
|
+
figure = Figure(figsize=(30, 4), dpi=100)
|
344
|
+
plot = figure.add_subplot(111)
|
345
|
+
plot.plot([], [])
|
346
|
+
plot.axis('off')
|
347
|
+
|
348
|
+
canvas = FigureCanvasTkAgg(figure, master=plot_frame)
|
349
|
+
canvas.get_tk_widget().configure(cursor='arrow', highlightthickness=0)
|
350
|
+
canvas_widget = canvas.get_tk_widget()
|
351
|
+
canvas_widget.grid(row=0, column=0, sticky="nsew")
|
352
|
+
|
353
|
+
plot_frame.grid_rowconfigure(0, weight=1)
|
354
|
+
plot_frame.grid_columnconfigure(0, weight=1)
|
355
|
+
|
356
|
+
canvas.draw()
|
357
|
+
canvas.figure = figure # Ensure that the figure is linked to the canvas
|
358
|
+
style_out = set_dark_style(ttk.Style())
|
359
|
+
bg = style_out['bg_color']
|
360
|
+
fg = style_out['fg_color']
|
361
|
+
|
362
|
+
figure.patch.set_facecolor(bg)
|
363
|
+
plot.set_facecolor(bg)
|
364
|
+
containers = [plot_frame]
|
365
|
+
|
366
|
+
# Create slider
|
367
|
+
control_frame = tk.Frame(plot_frame, height=15*2, bg=bg) # Fixed height based on knob_radius
|
368
|
+
control_frame.grid(row=1, column=0, sticky="ew", padx=10, pady=5)
|
369
|
+
control_frame.grid_propagate(False) # Prevent the frame from resizing
|
370
|
+
|
371
|
+
# Pass the update_figure function as the command to spacrSlider
|
372
|
+
index_control = spacrSlider(control_frame, from_=0, to=0, value=0, thickness=2, knob_radius=10, position="center", show_index=True, command=update_figure)
|
373
|
+
index_control.grid(row=0, column=0, sticky="ew")
|
374
|
+
control_frame.grid_columnconfigure(0, weight=1)
|
375
|
+
|
376
|
+
widgets = [canvas_widget, index_control]
|
377
|
+
style = ttk.Style(vertical_container)
|
378
|
+
_ = set_dark_style(style, containers=containers, widgets=widgets)
|
379
|
+
|
380
|
+
return canvas, canvas_widget
|
381
|
+
|
382
|
+
def set_globals(thread_control_var, q_var, console_output_var, parent_frame_var, vars_dict_var, canvas_var, canvas_widget_var, scrollable_frame_var, fig_queue_var, figures_var, figure_index_var, index_control_var, progress_bar_var, usage_bars_var):
|
383
|
+
global thread_control, q, console_output, parent_frame, vars_dict, canvas, canvas_widget, scrollable_frame, fig_queue, figures, figure_index, progress_bar, usage_bars, index_control
|
275
384
|
thread_control = thread_control_var
|
276
385
|
q = q_var
|
277
386
|
console_output = console_output_var
|
@@ -285,8 +394,7 @@ def set_globals(thread_control_var, q_var, console_output_var, parent_frame_var,
|
|
285
394
|
figure_index = figure_index_var
|
286
395
|
progress_bar = progress_bar_var
|
287
396
|
usage_bars = usage_bars_var
|
288
|
-
|
289
|
-
figure_current_memory_usage = figure_current_memory_usage_var
|
397
|
+
index_control = index_control_var
|
290
398
|
|
291
399
|
def import_settings(settings_type='mask'):
|
292
400
|
from .gui_utils import convert_settings_dict_for_gui, hide_all_settings
|
@@ -400,46 +508,6 @@ def setup_settings_panel(vertical_container, settings_type='mask'):
|
|
400
508
|
print("Settings panel setup complete")
|
401
509
|
return scrollable_frame, vars_dict
|
402
510
|
|
403
|
-
def setup_plot_section(vertical_container):
|
404
|
-
global canvas, canvas_widget, figures, figure_index
|
405
|
-
|
406
|
-
from .gui_elements import set_element_size
|
407
|
-
|
408
|
-
# Initialize deque for storing figures and the current index
|
409
|
-
figures = deque()
|
410
|
-
figure_index = -1
|
411
|
-
|
412
|
-
# Create a frame for the plot section
|
413
|
-
plot_frame = tk.Frame(vertical_container)
|
414
|
-
vertical_container.add(plot_frame, stretch="always")
|
415
|
-
|
416
|
-
# Set up the plot
|
417
|
-
figure = Figure(figsize=(30, 4), dpi=100)
|
418
|
-
plot = figure.add_subplot(111)
|
419
|
-
plot.plot([], [])
|
420
|
-
plot.axis('off')
|
421
|
-
|
422
|
-
canvas = FigureCanvasTkAgg(figure, master=plot_frame)
|
423
|
-
canvas.get_tk_widget().configure(cursor='arrow', highlightthickness=0)
|
424
|
-
canvas_widget = canvas.get_tk_widget()
|
425
|
-
canvas_widget.grid(row=0, column=0, sticky="nsew")
|
426
|
-
|
427
|
-
plot_frame.grid_rowconfigure(0, weight=1)
|
428
|
-
plot_frame.grid_columnconfigure(0, weight=1)
|
429
|
-
|
430
|
-
canvas.draw()
|
431
|
-
canvas.figure = figure # Ensure that the figure is linked to the canvas
|
432
|
-
style_out = set_dark_style(ttk.Style())
|
433
|
-
|
434
|
-
figure.patch.set_facecolor(style_out['bg_color'])
|
435
|
-
plot.set_facecolor(style_out['bg_color'])
|
436
|
-
containers = [plot_frame]
|
437
|
-
widgets = [canvas_widget]
|
438
|
-
style = ttk.Style(vertical_container)
|
439
|
-
_ = set_dark_style(style, containers=containers, widgets=widgets)
|
440
|
-
|
441
|
-
return canvas, canvas_widget
|
442
|
-
|
443
511
|
def setup_console(vertical_container):
|
444
512
|
global console_output
|
445
513
|
from .gui_elements import set_dark_style
|
@@ -479,27 +547,6 @@ def setup_console(vertical_container):
|
|
479
547
|
|
480
548
|
return console_output, console_frame
|
481
549
|
|
482
|
-
def setup_progress_frame(vertical_container):
|
483
|
-
global progress_output
|
484
|
-
style_out = set_dark_style(ttk.Style())
|
485
|
-
font_loader = style_out['font_loader']
|
486
|
-
font_size = style_out['font_size']
|
487
|
-
progress_frame = tk.Frame(vertical_container)
|
488
|
-
vertical_container.add(progress_frame, stretch="always")
|
489
|
-
label_frame = tk.Frame(progress_frame)
|
490
|
-
label_frame.grid(row=0, column=0, sticky="ew", pady=(5, 0), padx=10)
|
491
|
-
progress_label = spacrLabel(label_frame, text="Processing: 0%", font=font_loader.get_font(size=font_size), anchor='w', justify='left', align="left")
|
492
|
-
progress_label.grid(row=0, column=0, sticky="w")
|
493
|
-
progress_output = scrolledtext.ScrolledText(progress_frame, height=10)
|
494
|
-
progress_output.grid(row=1, column=0, sticky="nsew")
|
495
|
-
progress_frame.grid_rowconfigure(1, weight=1)
|
496
|
-
progress_frame.grid_columnconfigure(0, weight=1)
|
497
|
-
containers = [progress_frame, label_frame]
|
498
|
-
widgets = [progress_label, progress_output]
|
499
|
-
style = ttk.Style(vertical_container)
|
500
|
-
_ = set_dark_style(style, containers=containers, widgets=widgets)
|
501
|
-
return progress_output
|
502
|
-
|
503
550
|
def setup_button_section(horizontal_container, settings_type='mask', run=True, abort=True, download=True, import_btn=True):
|
504
551
|
global thread_control, parent_frame, button_frame, button_scrollable_frame, run_button, abort_button, download_dataset_button, import_button, q, fig_queue, vars_dict, progress_bar
|
505
552
|
from .gui_utils import download_hug_dataset
|
@@ -836,7 +883,7 @@ def initiate_root(parent, settings_type='mask'):
|
|
836
883
|
tuple: A tuple containing the parent frame and the dictionary of variables used in the GUI.
|
837
884
|
"""
|
838
885
|
|
839
|
-
global q, fig_queue, thread_control, parent_frame, scrollable_frame, button_frame, vars_dict, canvas, canvas_widget, button_scrollable_frame, progress_bar, uppdate_frequency, figures, figure_index,
|
886
|
+
global q, fig_queue, thread_control, parent_frame, scrollable_frame, button_frame, vars_dict, canvas, canvas_widget, button_scrollable_frame, progress_bar, uppdate_frequency, figures, figure_index, index_control, usage_bars
|
840
887
|
|
841
888
|
from .gui_utils import setup_frame
|
842
889
|
from .settings import descriptions
|
@@ -853,8 +900,6 @@ def initiate_root(parent, settings_type='mask'):
|
|
853
900
|
# Initialize global variables
|
854
901
|
figures = deque()
|
855
902
|
figure_index = -1
|
856
|
-
fig_memory_limit = 200 * 1024 * 1024 # 200 MB limit
|
857
|
-
figure_current_memory_usage = 0
|
858
903
|
|
859
904
|
parent_frame = parent
|
860
905
|
|
@@ -886,7 +931,7 @@ def initiate_root(parent, settings_type='mask'):
|
|
886
931
|
button_scrollable_frame, btn_col = setup_button_section(horizontal_container, settings_type)
|
887
932
|
_, usage_bars, btn_col = setup_usage_panel(horizontal_container, btn_col, uppdate_frequency)
|
888
933
|
|
889
|
-
set_globals(thread_control, q, console_output, parent_frame, vars_dict, canvas, canvas_widget, scrollable_frame, fig_queue, figures, figure_index, progress_bar, usage_bars
|
934
|
+
set_globals(thread_control, q, console_output, parent_frame, vars_dict, canvas, canvas_widget, scrollable_frame, fig_queue, figures, figure_index, index_control, progress_bar, usage_bars)
|
890
935
|
description_text = descriptions.get(settings_type, "No description available for this module.")
|
891
936
|
|
892
937
|
q.put(f"Console")
|
@@ -899,4 +944,6 @@ def initiate_root(parent, settings_type='mask'):
|
|
899
944
|
parent_window.after_tasks.append(after_id)
|
900
945
|
|
901
946
|
print("Root initialization complete")
|
902
|
-
return parent_frame, vars_dict
|
947
|
+
return parent_frame, vars_dict
|
948
|
+
|
949
|
+
|