Skip to content

Commit

Permalink
Use QCheckBox.setChecked rather than QCheckBox.setCheckState
Browse files Browse the repository at this point in the history
QCheckBox.setCheckState doesn't accept booleans as its for setting tristate checkboxes
  • Loading branch information
p-j-smith committed Aug 1, 2023
1 parent a9ca672 commit 8f07b29
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion btrack/napari/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions btrack/napari/widgets/_hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/napari/test_dock_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8f07b29

Please sign in to comment.