Skip to content

Commit 3db9a47

Browse files
authored
Merge pull request #48 from DeepLabCut/warn_unsaved
Warn about unsaved data rather than force users to save
2 parents ff412c3 + 7300afb commit 3db9a47

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/napari_deeplabcut/_tests/test_widgets.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ def test_store_crop_coordinates(viewer, images, config_path):
5353
def test_toggle_face_color(viewer, points):
5454
viewer.layers.selection.add(points)
5555
view = viewer.window._qt_viewer
56-
assert points._face.color_properties.name == "label"
57-
view.canvas.events.key_press(key=keys.Key('F'))
56+
# By default, points are colored by individual with multi-animal data
5857
assert points._face.color_properties.name == "id"
5958
view.canvas.events.key_press(key=keys.Key('F'))
6059
assert points._face.color_properties.name == "label"
60+
view.canvas.events.key_press(key=keys.Key('F'))
61+
assert points._face.color_properties.name == "id"
6162

6263

6364
def test_toggle_edge_color(viewer, points):

src/napari_deeplabcut/_widgets.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,16 @@ def _save_layers_dialog(self, selected=False):
114114

115115
def on_close(self, event, widget):
116116
if widget._stores and not widget._is_saved:
117-
QMessageBox.warning(
117+
choice = QMessageBox.warning(
118118
widget,
119-
"",
120-
"Please save your data before closing",
121-
QMessageBox.Ok,
119+
"Warning",
120+
"Data were not saved. Are you certain you want to leave?",
121+
QMessageBox.Yes | QMessageBox.No,
122122
)
123-
event.ignore()
123+
if choice == QMessageBox.Yes:
124+
event.accept()
125+
else:
126+
event.ignore()
124127
else:
125128
event.accept()
126129

@@ -142,7 +145,7 @@ def __init__(self, napari_viewer):
142145
status_bar = self.viewer.window._qt_window.statusBar()
143146
self.last_saved_label = QLabel("")
144147
self.last_saved_label.hide()
145-
status_bar.insertPermanentWidget(0, self.last_saved_label)
148+
status_bar.addPermanentWidget(self.last_saved_label)
146149

147150
# Hack napari's Welcome overlay to show more relevant instructions
148151
overlay = self.viewer.window._qt_viewer._canvas_overlay

0 commit comments

Comments
 (0)