Skip to content

Commit

Permalink
updated create_warning_box to include cancel option
Browse files Browse the repository at this point in the history
  • Loading branch information
Christina Bukas committed Dec 18, 2023
1 parent 5345dd2 commit 1dddad4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/client/dcp_client/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@ def on_item_inprogr_selected(self, item):

def on_train_button_clicked(self):
message_text = self.app.run_train()
create_warning_box(message_text)
_ = create_warning_box(message_text)

def on_run_inference_button_clicked(self):
message_text, message_title = self.app.run_inference()
create_warning_box(message_text, message_title)
_ = create_warning_box(message_text, message_title)

def on_launch_napari_button_clicked(self):
'''
Launches the napari window after the image is selected.
'''
if not self.app.cur_selected_img or '_seg.tiff' in self.app.cur_selected_img:
message_text = "Please first select an image you wish to visualise. The selected image must be an original images, not a mask."
create_warning_box(message_text, message_title="Warning")
_ = create_warning_box(message_text, message_title="Warning")
else:
self.nap_win = NapariWindow(self.app)
self.nap_win.show()
Expand Down
8 changes: 4 additions & 4 deletions src/client/dcp_client/gui/napari_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def on_add_to_curated_button_clicked(self):
'''
if self.app.cur_selected_path == str(self.app.train_data_path):
message_text = "Image is already in the \'Curated data\' folder and should not be changed again"
utils.create_warning_box(message_text, message_title="Warning")
_ = utils.create_warning_box(message_text, message_title="Warning")
return

# take the name of the currently selected layer (by the user)
cur_seg_selected = self.viewer.layers.selection.active.name
# TODO if more than one item is selected this will break!
if '_seg' not in cur_seg_selected:
message_text = "Please select the segmenation you wish to save from the layer list"
utils.create_warning_box(message_text, message_title="Warning")
_ = utils.create_warning_box(message_text, message_title="Warning")
return
seg = self.viewer.layers[cur_seg_selected].data

Expand All @@ -87,15 +87,15 @@ def on_add_to_inprogress_button_clicked(self):
# TODO: Do we allow this? What if they moved it by mistake? User can always manually move from their folders?)
if self.app.cur_selected_path == str(self.app.train_data_path):
message_text = "Images from '\Curated data'\ folder can not be moved back to \'Curatation in progress\' folder."
utils.create_warning_box(message_text, message_title="Warning")
_ = utils.create_warning_box(message_text, message_title="Warning")
return

# take the name of the currently selected layer (by the user)
cur_seg_selected = self.viewer.layers.selection.active.name
# TODO if more than one item is selected this will break!
if '_seg' not in cur_seg_selected:
message_text = "Please select the segmenation you wish to save from the layer list"
utils.create_warning_box(message_text, message_title="Warning")
_ = utils.create_warning_box(message_text, message_title="Warning")
return

# Move original image
Expand Down
6 changes: 3 additions & 3 deletions src/client/dcp_client/gui/welcome_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ def start_main(self):
self.mw = MainWindow(self.app)
else:
message_text = "You need to specify a folder both for your uncurated and curated dataset (even if the curated folder is currently empty). Please go back and select folders for both."
create_warning_box(message_text, message_title="Warning")
_ = create_warning_box(message_text, message_title="Warning")

def start_upload(self):
message_text = ("Your current configurations are set to run some operations on the cloud. \n"
"For this we need to upload your data to our server."
"We will now upload your data. Click ok to continue. \n"
"If you do not agree close the application and contact your software provider.")
create_warning_box(message_text, message_title="Warning")
self.app.upload_data_to_server()
usr_response = create_warning_box(message_text, message_title="Warning", add_cancel_btn=True)
if usr_response: self.app.upload_data_to_server()
self.hide()
self.mw = MainWindow(self.app)

11 changes: 8 additions & 3 deletions src/client/dcp_client/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ def icon(self, type: 'QFileIconProvider.IconType'):
else:
return super().icon(type)

def create_warning_box(message_text, message_title="Warning"):
def create_warning_box(message_text, message_title="Warning", add_cancel_btn=False):
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText(message_text)
msg.setWindowTitle(message_title)
msg.setStandardButtons(QMessageBox.Ok)
msg.exec()
if add_cancel_btn:
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)

Check warning on line 32 in src/client/dcp_client/utils/utils.py

View check run for this annotation

Codecov / codecov/patch

src/client/dcp_client/utils/utils.py#L31-L32

Added lines #L31 - L32 were not covered by tests
else:
msg.setStandardButtons(QMessageBox.Ok)
usr_response = msg.exec()
if usr_response == QMessageBox.Ok: return True
else: return False

Check warning on line 37 in src/client/dcp_client/utils/utils.py

View check run for this annotation

Codecov / codecov/patch

src/client/dcp_client/utils/utils.py#L34-L37

Added lines #L34 - L37 were not covered by tests

def read_config(name, config_path = 'config.cfg') -> dict:
"""Reads the configuration file
Expand Down

0 comments on commit 1dddad4

Please sign in to comment.