From 8f07b2977eca61bb6254de109b873e0a5accc2d6 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Tue, 1 Aug 2023 14:03:17 +0100 Subject: [PATCH] Use QCheckBox.setChecked rather than QCheckBox.setCheckState QCheckBox.setCheckState doesn't accept booleans as its for setting tristate checkboxes --- btrack/napari/sync.py | 2 +- btrack/napari/widgets/_hypothesis.py | 6 +++--- tests/napari/test_dock_widget.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/btrack/napari/sync.py b/btrack/napari/sync.py index f6e4b280..31e3ea21 100644 --- a/btrack/napari/sync.py +++ b/btrack/napari/sync.py @@ -91,7 +91,7 @@ def update_widgets_from_config( hypothesis_model = config.hypothesis_model for hypothesis in btrack.optimise.hypothesis.H_TYPES: is_checked = hypothesis in hypothesis_model.hypotheses - container[hypothesis].setCheckState(is_checked) + container[hypothesis].setChecked(is_checked) # Update widgets from HypothesisModel scaling factors for scaling_factor in btrack.napari.constants.HYPOTHESIS_SCALING_FACTORS: diff --git a/btrack/napari/widgets/_hypothesis.py b/btrack/napari/widgets/_hypothesis.py index fa0087f9..d16e0724 100644 --- a/btrack/napari/widgets/_hypothesis.py +++ b/btrack/napari/widgets/_hypothesis.py @@ -22,7 +22,7 @@ def _create_hypotheses_widgets() -> dict[str, QtWidgets.QWidget]: hypotheses_widgets = {} for hypothesis, tooltip in zip(hypotheses, tooltips): widget = QtWidgets.QCheckBox() - widget.setCheckState(True) # noqa: FBT003 + widget.setChecked(True) # noqa: FBT003 widget.setToolTip(tooltip) widget.setTristate(False) # noqa: FBT003 hypotheses_widgets[hypothesis] = (hypothesis, widget) @@ -31,7 +31,7 @@ def _create_hypotheses_widgets() -> dict[str, QtWidgets.QWidget]: hypotheses_widgets["P_FP"][1].setEnabled(False) # noqa: FBT003 # P_merge should be disabled by default - hypotheses_widgets["P_merge"][1].setCheckState(False) # noqa: FBT003 + hypotheses_widgets["P_merge"][1].setChecked(False) # noqa: FBT003 return hypotheses_widgets @@ -147,7 +147,7 @@ def create_hypothesis_model_widgets() -> dict[str, QtWidgets.QWidget]: widgets["segmentation_miss_rate"] = ("miss rate", segmentation_miss_rate) relax = QtWidgets.QCheckBox() - relax.setCheckState(True) # noqa: FBT003 + relax.setChecked(True) # noqa: FBT003 relax.setToolTip( "Disable the time and distance thresholds.\n" "This means that tracks can initialize or terminate anywhere and" diff --git a/tests/napari/test_dock_widget.py b/tests/napari/test_dock_widget.py index cb903fca..4ddbb26d 100644 --- a/tests/napari/test_dock_widget.py +++ b/tests/napari/test_dock_widget.py @@ -113,7 +113,7 @@ def test_reset_button(track_widget): track_widget.max_search_radius.setValue( track_widget.max_search_radius.value() + 10 ) - track_widget.relax.setCheckState(not track_widget.relax.checkState()) + track_widget.relax.setChecked(not track_widget.relax.checkState()) # click reset button - restores defaults of the currently-selected base config track_widget.reset_button.click()