From d3308e551c84f81022cf8b515fc308cec8e9f25e Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Wed, 17 Apr 2024 10:55:35 +0800 Subject: [PATCH] moninj: TTL widgets horizontal layout --- artiq/dashboard/moninj.py | 52 ++++++++++++--------------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/artiq/dashboard/moninj.py b/artiq/dashboard/moninj.py index e677231f8..57a0f0dbe 100644 --- a/artiq/dashboard/moninj.py +++ b/artiq/dashboard/moninj.py @@ -36,47 +36,37 @@ class _TTLWidget(QtWidgets.QFrame): self.setFrameShadow(QtWidgets.QFrame.Raised) grid = QtWidgets.QGridLayout() - grid.setContentsMargins(0, 0, 0, 0) - grid.setHorizontalSpacing(0) + grid.setContentsMargins(2, 2, 2, 2) + grid.setHorizontalSpacing(2) grid.setVerticalSpacing(0) self.setLayout(grid) label = QtWidgets.QLabel(title) - label.setAlignment(QtCore.Qt.AlignCenter) - label.setSizePolicy(QtWidgets.QSizePolicy.Ignored, - QtWidgets.QSizePolicy.Preferred) - grid.addWidget(label, 1, 1) + grid.addWidget(label, 0, 0) - self.stack = QtWidgets.QStackedWidget() - grid.addWidget(self.stack, 2, 1) - - self.direction = QtWidgets.QLabel() - self.direction.setAlignment(QtCore.Qt.AlignCenter) - self.stack.addWidget(self.direction) - - grid_cb = LayoutWidget() - grid_cb.layout.setContentsMargins(0, 0, 0, 0) - grid_cb.layout.setHorizontalSpacing(0) - grid_cb.layout.setVerticalSpacing(0) self.override = QtWidgets.QToolButton() self.override.setText("OVR") self.override.setCheckable(True) self.override.setToolTip("Override") - grid_cb.addWidget(self.override, 3, 1) + grid.addWidget(self.override, 0, 1) self.level = QtWidgets.QToolButton() self.level.setText("LVL") self.level.setCheckable(True) self.level.setToolTip("Level") - grid_cb.addWidget(self.level, 3, 2) - self.stack.addWidget(grid_cb) + grid.addWidget(self.level, 0, 2) + + self.direction = QtWidgets.QLabel() + self.direction.setAlignment(QtCore.Qt.AlignCenter) + grid.addWidget(self.direction, 0, 3) self.value = QtWidgets.QLabel() - self.value.setAlignment(QtCore.Qt.AlignCenter) - grid.addWidget(self.value, 3, 1) + self.value.setAlignment(QtCore.Qt.AlignRight) + grid.addWidget(self.value, 0, 4) - grid.setRowStretch(1, 1) - grid.setRowStretch(2, 0) - grid.setRowStretch(3, 0) - grid.setRowStretch(4, 1) + grid.setColumnStretch(0, 1) + grid.setColumnStretch(1, 1) + grid.setColumnStretch(2, 1) + grid.setColumnStretch(3, 1) + grid.setColumnStretch(4, 1) self.override.clicked.connect(self.override_toggled) self.level.clicked.connect(self.level_toggled) @@ -98,18 +88,8 @@ class _TTLWidget(QtWidgets.QFrame): def setButtonsState(self, override, level): self.override.setChecked(override) if override: - self.stack.setCurrentIndex(1) self.level.setChecked(level) - def enterEvent(self, event): - self.stack.setCurrentIndex(1) - QtWidgets.QFrame.enterEvent(self, event) - - def leaveEvent(self, event): - if not self.override.isChecked(): - self.stack.setCurrentIndex(0) - QtWidgets.QFrame.leaveEvent(self, event) - class _TTLHandler: def __init__(self, dm, channel, force_out, title):