Skip to content

Commit

Permalink
Disable save button when PCC is changed
Browse files Browse the repository at this point in the history
Disable the save button until features are extracted again with the new
PCC filtering.
  • Loading branch information
alexbolfa committed Dec 19, 2023
1 parent fbc7920 commit 622bb78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/napari_psf_extractor/components/pcc.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from napari.utils.notifications import show_error
from qtpy.QtCore import Signal
from qtpy.QtWidgets import QLineEdit, QHBoxLayout, QCheckBox, QWidget, QVBoxLayout, QLabel, QPushButton

from napari_psf_extractor.extractor import extract_psf


class PCC(QWidget):
changed = Signal()

def __init__(self, widget):
super().__init__()

Expand Down Expand Up @@ -34,6 +37,11 @@ def __init__(self, widget):
self.checkbox.stateChanged.connect(self.update_checkbox)
self.filter_button.clicked.connect(self.filter)

self.pcc_min.textChanged.connect(self.emit_changed)

def emit_changed(self):
self.changed.emit()

def update_checkbox(self):
if not self.checkbox.isChecked():
self.pcc_min.hide()
Expand All @@ -48,6 +56,8 @@ def update_checkbox(self):
self.pcc_min.setText("0.7")
self.features_pcc_label.setText("Remaining features:")

self.emit_changed()

def value(self):
"""
Get the current PCC value. If PCC filtering is not enabled, return None.
Expand Down
2 changes: 2 additions & 0 deletions src/napari_psf_extractor/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def param_setter(
self.extract_button.clicked.connect(self.extract)
self.find_features_button.clicked.connect(self.find_features)

self.pcc.changed.connect(lambda: self.save_button.setEnabled(False))

self.viewer.layers.events.inserted.connect(param_setter.reset_choices)
self.viewer.layers.events.removed.connect(param_setter.reset_choices)

Expand Down

0 comments on commit 622bb78

Please sign in to comment.