Skip to content

Commit 13a317b

Browse files
Merge pull request #981 from TheDeanLab/readonly-acquire-dropdown
Dropdown menu now read only
2 parents f8adf9d + 283c295 commit 13a317b

File tree

2 files changed

+29
-55
lines changed

2 files changed

+29
-55
lines changed

src/navigate/controller/sub_controllers/acquire_bar.py

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021-2022 The University of Texas Southwestern Medical Center.
1+
# Copyright (c) 2021-2024 The University of Texas Southwestern Medical Center.
22
# All rights reserved.
33

44
# Redistribution and use in source and binary forms, with or without
@@ -79,6 +79,7 @@ def __init__(self, view, parent_controller):
7979

8080
self.view.pull_down["values"] = list(self.mode_dict.keys())
8181
self.view.pull_down.current(0)
82+
self.view.pull_down.state(["!disabled", "readonly"])
8283

8384
# gui event bind
8485
self.view.acquire_btn.config(command=self.launch_popup_window)
@@ -248,16 +249,27 @@ def get_mode(self):
248249
return self.mode
249250

250251
def add_mode(self, mode):
252+
"""Add a new mode to the mode dictionary.
253+
254+
Parameters
255+
----------
256+
mode : str
257+
Mode to add to the dictionary.
258+
"""
251259
if mode not in self.mode_dict:
252260
self.mode_dict[mode] = mode
253261
self.view.pull_down["values"] = list(self.mode_dict.keys())
254262

255263
def stop_acquire(self):
256-
"""Stop the acquisition."""
264+
"""Stop the acquisition.
265+
266+
Stop the progress bar, set the acquire button back to "Acquire", place pull
267+
down menu in non-disabled format.
268+
"""
257269
self.stop_progress_bar()
258270
self.view.acquire_btn.configure(text="Acquire")
259271
self.view.acquire_btn.configure(state="normal")
260-
self.view.pull_down.configure(state="normal")
272+
self.view.pull_down.state(["!disabled", "readonly"])
261273
self.is_acquiring = False
262274

263275
def set_save_option(self, is_save):
@@ -267,10 +279,6 @@ def set_save_option(self, is_save):
267279
----------
268280
is_save : bool
269281
True if we will save the data. False if we will not.
270-
271-
Examples
272-
--------
273-
>>> set_save_option(True)
274282
"""
275283
self.is_save = is_save
276284
self.parent_controller.configuration["experiment"]["MicroscopeState"][
@@ -282,14 +290,9 @@ def launch_popup_window(self):
282290
"""Launch the Save Dialog Popup Window
283291
284292
The popup window should only be launched if the microscope is set to save the
285-
data, with the exception of the continuous acquisition mode.
286-
The popup window provides the user with the opportunity to fill in fields that
287-
describe the experiment and also dictate the save path of the data in a
288-
standardized format.
289-
290-
Examples
291-
--------
292-
>>> launch_popup_window()
293+
data, except the continuous acquisition mode. The popup window provides the
294+
user with the opportunity to fill in fields that describe the experiment and
295+
also dictate the save path of the data in a standardized format.
293296
"""
294297
if self.is_acquiring and self.view.acquire_btn["text"] == "Acquire":
295298
return
@@ -303,9 +306,7 @@ def launch_popup_window(self):
303306
elif self.is_save and self.mode != "live":
304307
#: object: Instance of the popup save dialog.
305308
self.acquire_pop = AcquirePopUp(self.view)
306-
buttons = (
307-
self.acquire_pop.get_buttons()
308-
) # This holds all the buttons in the popup
309+
buttons = self.acquire_pop.get_buttons()
309310
widgets = self.acquire_pop.get_widgets()
310311

311312
# Configure the button callbacks on the popup window
@@ -326,22 +327,20 @@ def launch_popup_window(self):
326327
else:
327328
self.is_acquiring = True
328329
self.view.acquire_btn.configure(state="disabled")
329-
self.view.pull_down.configure(state="disabled")
330+
# self.view.pull_down.configure(state="disabled")
331+
self.view.pull_down.state(["disabled", "readonly"])
332+
330333
self.parent_controller.execute("acquire")
331334

332335
def update_microscope_mode(self, *args):
333336
"""Gets the state of the pull-down menu and tells the central controller
334-
Will additionally call functions to disable and enable widgets based on mode
335337
336-
Parameters
338+
Will additionally call functions to disable and enable widgets based on mode
337339
340+
Parameters
338341
----------
339342
args : str
340343
Imaging Mode.
341-
342-
Examples
343-
--------
344-
>>> update_microscope_mode('live')
345344
"""
346345
self.mode = self.mode_dict[self.view.pull_down.get()]
347346
self.show_verbose_info("The Microscope State is now:", self.get_mode())
@@ -359,10 +358,6 @@ def update_file_type(self, file_type):
359358
----------
360359
file_type : str
361360
File type.
362-
363-
Examples
364-
--------
365-
>>> update_file_type('tiff')
366361
"""
367362
self.saving_settings["file_type"] = file_type.get()
368363

@@ -379,10 +374,6 @@ def launch_acquisition(self, popup_window):
379374
----------
380375
popup_window : object
381376
Instance of the popup save dialog.
382-
383-
Examples
384-
--------
385-
>>> launch_acquisition(popup_window)
386377
"""
387378
# update saving settings according to user's input
388379
self.update_experiment_values(popup_window)
@@ -404,26 +395,14 @@ def launch_acquisition(self, popup_window):
404395
self.parent_controller.execute("acquire_and_save")
405396

406397
def exit_program(self):
407-
"""Exit Button
408-
409-
Quit the software.
410-
411-
Examples
412-
--------
413-
>>> exit_program()
414-
"""
398+
"""Exit Button to close the program."""
415399
if messagebox.askyesno("Exit", "Are you sure?"):
416400
self.show_verbose_info("Exiting Program")
417401
# call the central controller to stop all the threads
418402
self.parent_controller.execute("exit")
419403

420404
def populate_experiment_values(self):
421-
"""Populate the experiment values from the config file.
422-
423-
Examples
424-
--------
425-
>>> populate_experiment_values()
426-
"""
405+
"""Populate the experiment values from the config file."""
427406
#: dict: Saving settings.
428407
self.saving_settings = self.parent_controller.configuration["experiment"][
429408
"Saving"
@@ -446,10 +425,6 @@ def update_experiment_values(self, popup_window):
446425
----------
447426
popup_window : object
448427
Instance of the popup save dialog.
449-
450-
Examples
451-
--------
452-
>>> update_experiment_values(popup_window)
453428
"""
454429
popup_vals = popup_window.get_variables()
455430
for name in popup_vals:

src/navigate/view/main_window_content/acquire_notebook.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def __init__(self, top_frame, root, *args, **kwargs):
8484
self.options = tk.StringVar()
8585
#: ttk.Combobox: Pull down menu to select acquisition type
8686
self.pull_down = ttk.Combobox(self, textvariable=self.options)
87-
self.pull_down.state(["readonly"])
8887

8988
# Progress Bar: Current Acquisitions and Overall
9089
#: ttk.Frame: Frame to hold the progress bars
@@ -104,9 +103,9 @@ def __init__(self, top_frame, root, *args, **kwargs):
104103
)
105104

106105
#: tk.Label: Label to display the current acquisition progress
107-
self.total_acquisition_label = tk.Label(self, text=f"{0:02}"
108-
f":{0:02}"
109-
f":{0:02}")
106+
self.total_acquisition_label = tk.Label(
107+
self, text=f"{0:02}" f":{0:02}" f":{0:02}"
108+
)
110109

111110
self.CurAcq.grid(row=0, column=0)
112111
self.OvrAcq.grid(row=1, column=0)

0 commit comments

Comments
 (0)