Skip to content

Commit

Permalink
Merge branch 'main' into fix-stage-wdg
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored Jul 18, 2024
2 parents 0d90036 + e1fc7cd commit 2b87d77
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
16 changes: 10 additions & 6 deletions src/pymmcore_widgets/_pixel_configuration_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ def __init__(
left_layout.setContentsMargins(0, 0, 0, 0)
left_layout.setSpacing(5)
self._px_table = _PixelTable()
affine_lbl = QLabel("Affine Transformations:")
affine_lbl = QLabel("Affine Transformation:")
self._affine_table = AffineTable()
left_layout.addWidget(self._px_table)
left_layout.addWidget(affine_lbl)
left_layout.addWidget(self._affine_table)
left_layout.addWidget(self._px_table, 1)
left_layout.addWidget(affine_lbl, 0)
left_layout.addWidget(self._affine_table, 0)

self._props_selector = _PropertySelector(mmcore=self._mmc)

Expand Down Expand Up @@ -473,7 +473,7 @@ def __init__(self, parent: QWidget | None = None):

self.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
self.horizontalHeader().setVisible(False)
self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
self.verticalHeader().setDefaultSectionSize(20)
self.verticalHeader().setVisible(False)

self.setColumnCount(3)
Expand All @@ -483,7 +483,11 @@ def __init__(self, parent: QWidget | None = None):
self._add_table_spinboxes()
self.setValue(DEFAULT_AFFINE)

self.setMaximumHeight(self.minimumSizeHint().height())
def sizeHint(self) -> Any:
sz = self.minimumSizeHint()
rc = self.rowCount()
sz.setHeight(self.rowHeight(0) * rc + (rc - 1))
return sz

def _add_table_spinboxes(self) -> None:
"""Add a spinbox in each cell of the table."""
Expand Down
6 changes: 3 additions & 3 deletions src/pymmcore_widgets/mda/_xy_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def __init__(
QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow
)
values_layout.addRow("Top:", self.top_edit)
values_layout.addRow("Left:", self.bottom_edit)
values_layout.addRow("Right:", self.left_edit)
values_layout.addRow("Bottom:", self.right_edit)
values_layout.addRow("Left:", self.left_edit)
values_layout.addRow("Right:", self.right_edit)
values_layout.addRow("Bottom:", self.bottom_edit)

top_layout = QHBoxLayout()
top_layout.setContentsMargins(0, 0, 0, 0)
Expand Down
6 changes: 6 additions & 0 deletions src/pymmcore_widgets/useq_widgets/_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ def __init__(self, parent: QWidget | None = None):
self.order.currentIndexChanged.connect(self._on_change)
self.relative_to.currentIndexChanged.connect(self._on_change)

# FIXME: On Windows 11, buttons within an inner widget of a ScrollArea
# are filled in with the accent color, making it very difficult to see
# which radio button is checked. This HACK solves the issue. It's
# likely future Qt versions will fix this.
inner_widget.setStyleSheet("QRadioButton {color: none}")

# ------------------------- Public API -------------------------

def mode(self) -> Mode:
Expand Down
17 changes: 13 additions & 4 deletions src/pymmcore_widgets/useq_widgets/_mda_sequence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from importlib.util import find_spec
from itertools import permutations
from pathlib import Path
from typing import cast
Expand Down Expand Up @@ -297,10 +298,10 @@ def __init__(
)
self._duration_label.setWordWrap(True)

self._save_button = QPushButton("Save")
self._save_button = QPushButton("Save Settings")
self._save_button.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self._save_button.clicked.connect(self.save)
self._load_button = QPushButton("Load")
self._load_button = QPushButton("Load Settings")
self._load_button.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self._load_button.clicked.connect(self.load)

Expand Down Expand Up @@ -439,7 +440,7 @@ def save(self, file: str | Path | None = None) -> None:
self,
"Save MDASequence and filename.",
"",
"All (*.yaml *yml *json);;YAML (*.yaml *.yml);;JSON (*.json)",
self._settings_extensions(),
)
if not file: # pragma: no cover
return
Expand Down Expand Up @@ -467,7 +468,7 @@ def load(self, file: str | Path | None = None) -> None:
self,
"Select an MDAsequence file.",
"",
"All (*.yaml *yml *json);;YAML (*.yaml *.yml);;JSON (*.json)",
self._settings_extensions(),
)
if not file: # pragma: no cover
return
Expand All @@ -485,6 +486,14 @@ def load(self, file: str | Path | None = None) -> None:

# -------------- Private API --------------

def _settings_extensions(self) -> str:
"""Returns the available extensions for MDA settings save/load."""
if find_spec("yaml") is not None:
# YAML available
return "All (*.yaml *yml *.json);;YAML (*.yaml *.yml);;JSON (*.json)"
# Only JSON
return "All (*.json);;JSON (*.json)"

def _on_af_toggled(self, checked: bool) -> None:
# if the 'af_per_position' checkbox in the PositionTable is checked, set checked
# also the autofocus p axis checkbox.
Expand Down

0 comments on commit 2b87d77

Please sign in to comment.