spacr 0.1.1__py3-none-any.whl → 0.1.11__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/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.geometry("1000x800")
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 Settings", command=lambda: import_settings(scrollable_frame))
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.geometry("1000x800")
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():
@@ -64,7 +68,7 @@ def create_menu_bar(root):
64
68
  from .gui_mask_app import initiate_mask_root
65
69
  from .gui_measure_app import initiate_measure_root
66
70
  from .annotate_app import initiate_annotation_app_root
67
- from .mask_app import initiate_mask_app_root
71
+ from .gui_make_masks_app import initiate_mask_app_root
68
72
  from .gui_classify_app import initiate_classify_root
69
73
 
70
74
  gui_apps = {
@@ -92,6 +96,66 @@ 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 load_app(root, app_name, app_func):
100
+ # Cancel all scheduled after tasks
101
+ if hasattr(root, 'after_tasks'):
102
+ for task in root.after_tasks:
103
+ root.after_cancel(task)
104
+ root.after_tasks = []
105
+
106
+ def proceed_with_app():
107
+ # Clear the current content frame
108
+ if hasattr(root, 'content_frame'):
109
+ for widget in root.content_frame.winfo_children():
110
+ widget.destroy()
111
+ else:
112
+ root.content_frame = tk.Frame(root)
113
+ root.content_frame.grid(row=1, column=0, sticky="nsew")
114
+ root.grid_rowconfigure(1, weight=1)
115
+ root.grid_columnconfigure(0, weight=1)
116
+
117
+ # Initialize the new app in the content frame
118
+ app_func(root.content_frame)
119
+
120
+ # Exit functionality only for the annotation app
121
+ if app_name != "Annotate" and hasattr(root, 'current_app_exit_func'):
122
+ root.next_app_func = proceed_with_app
123
+ root.current_app_exit_func()
124
+ else:
125
+ proceed_with_app()
126
+
127
+ def create_menu_bar(root):
128
+ from .gui_mask_app import initiate_mask_root
129
+ from .gui_measure_app import initiate_measure_root
130
+ from .annotate_app import initiate_annotation_app_root
131
+ from .gui_make_masks_app import initiate_mask_app_root
132
+ from .gui_classify_app import initiate_classify_root
133
+
134
+ gui_apps = {
135
+ "Mask": initiate_mask_root,
136
+ "Measure": initiate_measure_root,
137
+ "Annotate": initiate_annotation_app_root,
138
+ "Make Masks": initiate_mask_app_root,
139
+ "Classify": initiate_classify_root
140
+ }
141
+
142
+ def load_app_wrapper(app_name, app_func):
143
+ load_app(root, app_name, app_func)
144
+
145
+ # Create the menu bar
146
+ menu_bar = tk.Menu(root, bg="#008080", fg="white")
147
+ # Create a "SpaCr Applications" menu
148
+ app_menu = tk.Menu(menu_bar, tearoff=0, bg="#008080", fg="white")
149
+ menu_bar.add_cascade(label="SpaCr Applications", menu=app_menu)
150
+ # Add options to the "SpaCr Applications" menu
151
+ for app_name, app_func in gui_apps.items():
152
+ app_menu.add_command(label=app_name, command=lambda app_name=app_name, app_func=app_func: load_app_wrapper(app_name, app_func))
153
+ # Add a separator and an exit option
154
+ app_menu.add_separator()
155
+ app_menu.add_command(label="Exit", command=root.destroy) # Use root.destroy instead of root.quit
156
+ # Configure the menu for the root window
157
+ root.config(menu=menu_bar)
158
+
95
159
  class CustomButton(tk.Frame):
96
160
  def __init__(self, parent, text="", command=None, font=None, *args, **kwargs):
97
161
  super().__init__(parent, *args, **kwargs)
@@ -275,19 +339,6 @@ def check_and_download_font_v1():
275
339
  tkFont.nametofont("TkTextFont").configure(family=font_name, size=10)
276
340
  tkFont.nametofont("TkHeadingFont").configure(family=font_name, size=12)
277
341
 
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
342
  def check_and_download_font():
292
343
  font_name = "Helvetica"
293
344
  font_dir = "fonts"
@@ -320,7 +371,7 @@ def check_and_download_font():
320
371
  tkFont.nametofont("TkTextFont").configure(family=font_name, size=10)
321
372
  tkFont.nametofont("TkHeadingFont").configure(family=font_name, size=12)
322
373
 
323
- def style_text_boxes(style):
374
+ def style_text_boxes_v1(style):
324
375
  check_and_download_font()
325
376
  font_style = tkFont.Font(family="Helvetica", size=10) # Define the Helvetica font
326
377
  style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground='#000000', foreground='#ffffff', font=font_style)
@@ -333,6 +384,19 @@ def style_text_boxes(style):
333
384
  style.configure('TCheckbutton', background='#333333', foreground='#ffffff', indicatoron=False, relief='flat', font=font_style)
334
385
  style.map('TCheckbutton', background=[('selected', '#555555'), ('active', '#555555')])
335
386
 
387
+ def style_text_boxes(style):
388
+ font_style = tkFont.Font(family="Helvetica", size=10)
389
+ style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground='#333333', foreground='#ffffff', font=font_style)
390
+ style.configure('TCombobox', fieldbackground='#333333', background='#333333', foreground='#ffffff', font=font_style)
391
+ style.configure('Custom.TButton', padding='10 10 10 10', borderwidth=1, relief='solid', background='#008080', foreground='#ffffff', font=font_style)
392
+ style.map('Custom.TButton',
393
+ background=[('active', '#66b2b2'), ('disabled', '#004d4d'), ('!disabled', '#008080')],
394
+ foreground=[('active', '#ffffff'), ('disabled', '#888888')])
395
+ style.configure('Custom.TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background='#000000', foreground='#ffffff', font=font_style)
396
+ style.configure('TCheckbutton', background='#333333', foreground='#ffffff', indicatoron=False, relief='flat', font=font_style)
397
+ style.map('TCheckbutton', background=[('selected', '#555555'), ('active', '#555555')])
398
+
399
+
336
400
 
337
401
  def read_settings_from_csv(csv_file_path):
338
402
  settings = {}