spacr 0.1.1__py3-none-any.whl → 0.1.12__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/__init__.py +12 -12
- spacr/annotate_app.py +258 -99
- spacr/annotate_app_v2.py +163 -4
- spacr/app_annotate.py +539 -0
- spacr/app_classify.py +201 -0
- spacr/app_make_masks.py +929 -0
- spacr/app_make_masks_v2.py +688 -0
- spacr/app_mask.py +251 -0
- spacr/app_measure.py +248 -0
- spacr/classify_app.py +201 -0
- spacr/gui.py +23 -20
- spacr/gui_annotate.py +145 -0
- spacr/gui_classify_app.py +20 -6
- spacr/gui_make_masks_app.py +927 -0
- spacr/gui_make_masks_app_v2.py +688 -0
- spacr/gui_mask_app.py +8 -4
- spacr/gui_measure_app.py +15 -5
- spacr/gui_utils.py +110 -20
- spacr/make_masks_app.py +929 -0
- spacr/make_masks_app_v2.py +688 -0
- spacr/mask_app.py +239 -915
- spacr/measure_app.py +246 -0
- spacr/sim_app.py +0 -0
- {spacr-0.1.1.dist-info → spacr-0.1.12.dist-info}/METADATA +5 -1
- spacr-0.1.12.dist-info/RECORD +54 -0
- {spacr-0.1.1.dist-info → spacr-0.1.12.dist-info}/entry_points.txt +3 -3
- spacr-0.1.1.dist-info/RECORD +0 -40
- {spacr-0.1.1.dist-info → spacr-0.1.12.dist-info}/LICENSE +0 -0
- {spacr-0.1.1.dist-info → spacr-0.1.12.dist-info}/WHEEL +0 -0
- {spacr-0.1.1.dist-info → spacr-0.1.12.dist-info}/top_level.txt +0 -0
spacr/gui_mask_app.py
CHANGED
@@ -174,13 +174,15 @@ def initiate_mask_root(parent_frame):
|
|
174
174
|
vars_dict['Test mode'] = (None, None, tk.BooleanVar(value=False))
|
175
175
|
|
176
176
|
# Button section
|
177
|
-
test_mode_button = CustomButton(scrollable_frame.scrollable_frame, text="Test Mode", command=toggle_test_mode)
|
177
|
+
test_mode_button = CustomButton(scrollable_frame.scrollable_frame, text="Test Mode", command=toggle_test_mode, font=('Helvetica', 10))
|
178
|
+
#CustomButton(buttons_frame, text=app_name, command=lambda app_name=app_name: self.load_app(app_name, app_func), font=('Helvetica', 12))
|
179
|
+
|
178
180
|
test_mode_button.grid(row=47, column=1, pady=10, padx=10)
|
179
|
-
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import", command=lambda: import_settings(scrollable_frame))
|
181
|
+
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import", command=lambda: import_settings(scrollable_frame), font=('Helvetica', 10))
|
180
182
|
import_btn.grid(row=47, column=0, pady=10, padx=10)
|
181
183
|
run_button = CustomButton(scrollable_frame.scrollable_frame, text="Run", command=lambda: start_process(q, fig_queue))
|
182
184
|
run_button.grid(row=45, column=0, pady=10, padx=10)
|
183
|
-
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort)
|
185
|
+
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort, font=('Helvetica', 10))
|
184
186
|
abort_button.grid(row=45, column=1, pady=10, padx=10)
|
185
187
|
progress_label = ttk.Label(scrollable_frame.scrollable_frame, text="Processing: 0%", background="black", foreground="white")
|
186
188
|
progress_label.grid(row=50, column=0, columnspan=2, sticky="ew", pady=(5, 0), padx=10)
|
@@ -223,7 +225,9 @@ def initiate_mask_root(parent_frame):
|
|
223
225
|
|
224
226
|
def gui_mask():
|
225
227
|
root = tk.Tk()
|
226
|
-
root.
|
228
|
+
width = root.winfo_screenwidth()
|
229
|
+
height = root.winfo_screenheight()
|
230
|
+
root.geometry(f"{width}x{height}")
|
227
231
|
root.title("SpaCr: generate masks")
|
228
232
|
|
229
233
|
# Clear previous content if any
|
spacr/gui_measure_app.py
CHANGED
@@ -19,6 +19,15 @@ from .gui_utils import measure_variables, measure_crop_wrapper, clear_canvas, ch
|
|
19
19
|
|
20
20
|
thread_control = {"run_thread": None, "stop_requested": False}
|
21
21
|
|
22
|
+
def import_settings(scrollable_frame):
|
23
|
+
global vars_dict
|
24
|
+
|
25
|
+
csv_file_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
|
26
|
+
csv_settings = read_settings_from_csv(csv_file_path)
|
27
|
+
variables = measure_variables()
|
28
|
+
new_settings = update_settings_from_csv(variables, csv_settings)
|
29
|
+
vars_dict = generate_fields(new_settings, scrollable_frame)
|
30
|
+
|
22
31
|
def toggle_test_mode():
|
23
32
|
global vars_dict
|
24
33
|
current_state = vars_dict['test_mode'][2].get()
|
@@ -166,11 +175,11 @@ def initiate_measure_root(parent_frame):
|
|
166
175
|
# Button section
|
167
176
|
test_mode_button = CustomButton(scrollable_frame.scrollable_frame, text="Test Mode", command=toggle_test_mode)
|
168
177
|
test_mode_button.grid(row=47, column=1, pady=10, padx=10)
|
169
|
-
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import
|
178
|
+
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import", command=lambda: import_settings(scrollable_frame), font=('Helvetica', 10))
|
170
179
|
import_btn.grid(row=47, column=0, pady=20, padx=20)
|
171
|
-
run_button = CustomButton(scrollable_frame.scrollable_frame, text="Run", command=lambda: start_process(q, fig_queue))
|
180
|
+
run_button = CustomButton(scrollable_frame.scrollable_frame, text="Run", command=lambda: start_process(q, fig_queue), font=('Helvetica', 10))
|
172
181
|
run_button.grid(row=45, column=0, pady=20, padx=20)
|
173
|
-
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort)
|
182
|
+
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort, font=('Helvetica', 10))
|
174
183
|
abort_button.grid(row=45, column=1, pady=20, padx=20)
|
175
184
|
progress_label = ttk.Label(scrollable_frame.scrollable_frame, text="Processing: 0%", background="black", foreground="white") # Create progress field
|
176
185
|
progress_label.grid(row=50, column=0, columnspan=2, sticky="ew", pady=(5, 0), padx=10)
|
@@ -211,10 +220,11 @@ def initiate_measure_root(parent_frame):
|
|
211
220
|
|
212
221
|
return parent_frame, vars_dict
|
213
222
|
|
214
|
-
|
215
223
|
def gui_measure():
|
216
224
|
root = tk.Tk()
|
217
|
-
root.
|
225
|
+
width = root.winfo_screenwidth()
|
226
|
+
height = root.winfo_screenheight()
|
227
|
+
root.geometry(f"{width}x{height}")
|
218
228
|
root.title("SpaCr: measure objects")
|
219
229
|
|
220
230
|
# Clear previous content if any
|
spacr/gui_utils.py
CHANGED
@@ -47,6 +47,10 @@ def load_app(root, app_name, app_func):
|
|
47
47
|
root.after_cancel(task)
|
48
48
|
root.after_tasks = []
|
49
49
|
|
50
|
+
# Exit functionality only for the annotation app
|
51
|
+
if app_name == "Annotate" and hasattr(root, 'current_app_exit_func'):
|
52
|
+
root.current_app_exit_func()
|
53
|
+
|
50
54
|
# Clear the current content frame
|
51
55
|
if hasattr(root, 'content_frame'):
|
52
56
|
for widget in root.content_frame.winfo_children():
|
@@ -61,11 +65,11 @@ def load_app(root, app_name, app_func):
|
|
61
65
|
app_func(root.content_frame)
|
62
66
|
|
63
67
|
def create_menu_bar(root):
|
64
|
-
from .
|
65
|
-
from .
|
66
|
-
from .
|
67
|
-
from .
|
68
|
-
from .
|
68
|
+
from .app_mask import initiate_mask_root
|
69
|
+
from .app_measure import initiate_measure_root
|
70
|
+
from .app_annotate import initiate_annotation_app_root
|
71
|
+
from .app_make_masks import initiate_mask_app_root
|
72
|
+
from .app_classify import initiate_classify_root
|
69
73
|
|
70
74
|
gui_apps = {
|
71
75
|
"Mask": initiate_mask_root,
|
@@ -92,6 +96,92 @@ def create_menu_bar(root):
|
|
92
96
|
# Configure the menu for the root window
|
93
97
|
root.config(menu=menu_bar)
|
94
98
|
|
99
|
+
def proceed_with_app(root, app_name, app_func):
|
100
|
+
|
101
|
+
from .app_mask import gui_mask
|
102
|
+
from .app_measure import gui_measure
|
103
|
+
from .app_annotate import gui_annotate
|
104
|
+
from .app_make_masks import gui_make_masks
|
105
|
+
from .app_classify import gui_classify
|
106
|
+
from .gui import gui_app
|
107
|
+
|
108
|
+
# Clear the current content frame
|
109
|
+
if hasattr(root, 'content_frame'):
|
110
|
+
for widget in root.content_frame.winfo_children():
|
111
|
+
widget.destroy()
|
112
|
+
else:
|
113
|
+
root.content_frame = tk.Frame(root)
|
114
|
+
root.content_frame.grid(row=1, column=0, sticky="nsew")
|
115
|
+
root.grid_rowconfigure(1, weight=1)
|
116
|
+
root.grid_columnconfigure(0, weight=1)
|
117
|
+
|
118
|
+
# Initialize the new app in the content frame
|
119
|
+
if app_name == "Main App":
|
120
|
+
root.destroy() # Close the current window
|
121
|
+
gui_app() # Open the main app window
|
122
|
+
elif app_name == "Mask":
|
123
|
+
gui_mask()
|
124
|
+
elif app_name == "Measure":
|
125
|
+
gui_measure()
|
126
|
+
elif app_name == "Annotate":
|
127
|
+
gui_annotate()
|
128
|
+
elif app_name == "Make Masks":
|
129
|
+
gui_make_masks()
|
130
|
+
elif app_name == "Classify":
|
131
|
+
gui_classify()
|
132
|
+
else:
|
133
|
+
raise ValueError(f"Invalid app name: {app_name}")
|
134
|
+
|
135
|
+
def load_app(root, app_name, app_func):
|
136
|
+
# Cancel all scheduled after tasks
|
137
|
+
if hasattr(root, 'after_tasks'):
|
138
|
+
for task in root.after_tasks:
|
139
|
+
root.after_cancel(task)
|
140
|
+
root.after_tasks = []
|
141
|
+
|
142
|
+
# Exit functionality only for the annotation app
|
143
|
+
if app_name != "Annotate" and hasattr(root, 'current_app_exit_func'):
|
144
|
+
root.next_app_func = proceed_with_app
|
145
|
+
root.next_app_args = (app_name, app_func) # Ensure correct arguments
|
146
|
+
root.current_app_exit_func()
|
147
|
+
else:
|
148
|
+
proceed_with_app(root, app_name, app_func)
|
149
|
+
|
150
|
+
|
151
|
+
def create_menu_bar(root):
|
152
|
+
from .app_mask import initiate_mask_root
|
153
|
+
from .app_measure import initiate_measure_root
|
154
|
+
from .app_annotate import initiate_annotation_app_root
|
155
|
+
from .app_make_masks import initiate_mask_app_root
|
156
|
+
from .app_classify import initiate_classify_root
|
157
|
+
from .gui import gui_app
|
158
|
+
|
159
|
+
gui_apps = {
|
160
|
+
"Main App": gui_app,
|
161
|
+
"Mask": initiate_mask_root,
|
162
|
+
"Measure": initiate_measure_root,
|
163
|
+
"Annotate": initiate_annotation_app_root,
|
164
|
+
"Make Masks": initiate_mask_app_root,
|
165
|
+
"Classify": initiate_classify_root
|
166
|
+
}
|
167
|
+
|
168
|
+
def load_app_wrapper(app_name, app_func):
|
169
|
+
load_app(root, app_name, app_func)
|
170
|
+
|
171
|
+
# Create the menu bar
|
172
|
+
menu_bar = tk.Menu(root, bg="#008080", fg="white")
|
173
|
+
# Create a "SpaCr Applications" menu
|
174
|
+
app_menu = tk.Menu(menu_bar, tearoff=0, bg="#008080", fg="white")
|
175
|
+
menu_bar.add_cascade(label="SpaCr Applications", menu=app_menu)
|
176
|
+
# Add options to the "SpaCr Applications" menu
|
177
|
+
for app_name, app_func in gui_apps.items():
|
178
|
+
app_menu.add_command(label=app_name, command=lambda app_name=app_name, app_func=app_func: load_app_wrapper(app_name, app_func))
|
179
|
+
# Add a separator and an exit option
|
180
|
+
app_menu.add_separator()
|
181
|
+
app_menu.add_command(label="Exit", command=root.destroy) # Use root.destroy instead of root.quit
|
182
|
+
# Configure the menu for the root window
|
183
|
+
root.config(menu=menu_bar)
|
184
|
+
|
95
185
|
class CustomButton(tk.Frame):
|
96
186
|
def __init__(self, parent, text="", command=None, font=None, *args, **kwargs):
|
97
187
|
super().__init__(parent, *args, **kwargs)
|
@@ -275,19 +365,6 @@ def check_and_download_font_v1():
|
|
275
365
|
tkFont.nametofont("TkTextFont").configure(family=font_name, size=10)
|
276
366
|
tkFont.nametofont("TkHeadingFont").configure(family=font_name, size=12)
|
277
367
|
|
278
|
-
def style_text_boxes_v1(style):
|
279
|
-
check_and_download_font()
|
280
|
-
font_style = tkFont.Font(family="Helvetica", size=10) # Define the Helvetica font
|
281
|
-
style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground='#000000', foreground='#ffffff', font=font_style)
|
282
|
-
style.configure('TCombobox', fieldbackground='#000000', background='#000000', foreground='#ffffff', font=font_style)
|
283
|
-
style.configure('Custom.TButton', padding='10 10 10 10', borderwidth=1, relief='solid', background='#008080', foreground='#ffffff', font=font_style)
|
284
|
-
style.map('Custom.TButton',
|
285
|
-
background=[('active', '#66b2b2'), ('disabled', '#004d4d'), ('!disabled', '#008080')],
|
286
|
-
foreground=[('active', '#ffffff'), ('disabled', '#888888')])
|
287
|
-
style.configure('Custom.TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background='#000000', foreground='#ffffff', font=font_style)
|
288
|
-
style.configure('TCheckbutton', background='#333333', foreground='#ffffff', indicatoron=False, relief='flat', font=font_style)
|
289
|
-
style.map('TCheckbutton', background=[('selected', '#555555'), ('active', '#555555')])
|
290
|
-
|
291
368
|
def check_and_download_font():
|
292
369
|
font_name = "Helvetica"
|
293
370
|
font_dir = "fonts"
|
@@ -320,7 +397,7 @@ def check_and_download_font():
|
|
320
397
|
tkFont.nametofont("TkTextFont").configure(family=font_name, size=10)
|
321
398
|
tkFont.nametofont("TkHeadingFont").configure(family=font_name, size=12)
|
322
399
|
|
323
|
-
def
|
400
|
+
def style_text_boxes_v1(style):
|
324
401
|
check_and_download_font()
|
325
402
|
font_style = tkFont.Font(family="Helvetica", size=10) # Define the Helvetica font
|
326
403
|
style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground='#000000', foreground='#ffffff', font=font_style)
|
@@ -330,9 +407,22 @@ def style_text_boxes(style):
|
|
330
407
|
background=[('active', '#66b2b2'), ('disabled', '#004d4d'), ('!disabled', '#008080')],
|
331
408
|
foreground=[('active', '#ffffff'), ('disabled', '#888888')])
|
332
409
|
style.configure('Custom.TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background='#000000', foreground='#ffffff', font=font_style)
|
333
|
-
style.configure('TCheckbutton', background='
|
410
|
+
style.configure('TCheckbutton', background='black', foreground='#ffffff', indicatoron=False, relief='flat', font=font_style)
|
334
411
|
style.map('TCheckbutton', background=[('selected', '#555555'), ('active', '#555555')])
|
335
412
|
|
413
|
+
def style_text_boxes(style):
|
414
|
+
font_style = tkFont.Font(family="Helvetica", size=10)
|
415
|
+
style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground='black', foreground='#ffffff', font=font_style)
|
416
|
+
style.configure('TCombobox', fieldbackground='black', background='black', foreground='#ffffff', font=font_style)
|
417
|
+
style.configure('Custom.TButton', padding='10 10 10 10', borderwidth=1, relief='solid', background='#008080', foreground='#ffffff', font=font_style)
|
418
|
+
style.map('Custom.TButton',
|
419
|
+
background=[('active', '#66b2b2'), ('disabled', '#004d4d'), ('!disabled', '#008080')],
|
420
|
+
foreground=[('active', '#ffffff'), ('disabled', '#888888')])
|
421
|
+
style.configure('Custom.TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background='#000000', foreground='#ffffff', font=font_style)
|
422
|
+
style.configure('TCheckbutton', background='black', foreground='#ffffff', indicatoron=False, relief='flat', font=font_style)
|
423
|
+
style.map('TCheckbutton', background=[('selected', '#555555'), ('active', '#555555')])
|
424
|
+
|
425
|
+
|
336
426
|
|
337
427
|
def read_settings_from_csv(csv_file_path):
|
338
428
|
settings = {}
|