forked from M-Labs/artiq
moninj: DDS change to vert layout
This commit is contained in:
parent
a7478a907c
commit
81f3dc9d41
@ -153,85 +153,62 @@ class _DDSWidget(QtWidgets.QFrame):
|
|||||||
self.setFrameShadow(QtWidgets.QFrame.Raised)
|
self.setFrameShadow(QtWidgets.QFrame.Raised)
|
||||||
|
|
||||||
grid = QtWidgets.QGridLayout()
|
grid = QtWidgets.QGridLayout()
|
||||||
grid.setContentsMargins(0, 0, 0, 0)
|
grid.setContentsMargins(2, 2, 2, 2)
|
||||||
grid.setHorizontalSpacing(0)
|
grid.setHorizontalSpacing(2)
|
||||||
grid.setVerticalSpacing(0)
|
|
||||||
self.setLayout(grid)
|
self.setLayout(grid)
|
||||||
label = QtWidgets.QLabel(title)
|
label = QtWidgets.QLabel(title)
|
||||||
label.setAlignment(QtCore.Qt.AlignCenter)
|
label.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
grid.addWidget(label, 1, 1)
|
grid.addWidget(label, 0, 0)
|
||||||
|
|
||||||
# FREQ DATA/EDIT FIELD
|
self.stack = QtWidgets.QStackedWidget()
|
||||||
self.data_stack = QtWidgets.QStackedWidget()
|
|
||||||
|
|
||||||
# page 1: display data
|
|
||||||
grid_disp = LayoutWidget()
|
grid_disp = LayoutWidget()
|
||||||
grid_disp.layout.setContentsMargins(0, 0, 0, 0)
|
grid_disp.layout.setContentsMargins(0, 0, 0, 0)
|
||||||
grid_disp.layout.setHorizontalSpacing(0)
|
grid_disp.layout.setHorizontalSpacing(0)
|
||||||
grid_disp.layout.setVerticalSpacing(0)
|
|
||||||
|
|
||||||
self.value_label = QtWidgets.QLabel()
|
|
||||||
self.value_label.setAlignment(QtCore.Qt.AlignCenter)
|
|
||||||
grid_disp.addWidget(self.value_label, 0, 1, 1, 2)
|
|
||||||
|
|
||||||
unit = QtWidgets.QLabel("MHz")
|
|
||||||
unit.setAlignment(QtCore.Qt.AlignCenter)
|
|
||||||
grid_disp.addWidget(unit, 0, 3, 1, 1)
|
|
||||||
|
|
||||||
self.data_stack.addWidget(grid_disp)
|
|
||||||
|
|
||||||
# page 2: edit data
|
|
||||||
grid_edit = LayoutWidget()
|
|
||||||
grid_edit.layout.setContentsMargins(0, 0, 0, 0)
|
|
||||||
grid_edit.layout.setHorizontalSpacing(0)
|
|
||||||
grid_edit.layout.setVerticalSpacing(0)
|
|
||||||
|
|
||||||
self.value_edit = _CancellableLineEdit(self)
|
|
||||||
self.value_edit.setAlignment(QtCore.Qt.AlignRight)
|
|
||||||
grid_edit.addWidget(self.value_edit, 0, 1, 1, 2)
|
|
||||||
unit = QtWidgets.QLabel("MHz")
|
|
||||||
unit.setAlignment(QtCore.Qt.AlignCenter)
|
|
||||||
grid_edit.addWidget(unit, 0, 3, 1, 1)
|
|
||||||
self.data_stack.addWidget(grid_edit)
|
|
||||||
|
|
||||||
grid.addWidget(self.data_stack, 2, 1)
|
|
||||||
|
|
||||||
# BUTTONS
|
|
||||||
self.button_stack = QtWidgets.QStackedWidget()
|
|
||||||
|
|
||||||
# page 1: SET button
|
|
||||||
set_grid = LayoutWidget()
|
|
||||||
|
|
||||||
set_btn = QtWidgets.QToolButton()
|
set_btn = QtWidgets.QToolButton()
|
||||||
set_btn.setText("Set")
|
set_btn.setText("Set")
|
||||||
set_btn.setToolTip("Set frequency")
|
set_btn.setToolTip("Set frequency")
|
||||||
set_grid.addWidget(set_btn, 0, 1, 1, 1)
|
|
||||||
|
|
||||||
# for urukuls also allow switching off RF
|
# for urukuls also allow switching off RF
|
||||||
if is_urukul:
|
if is_urukul:
|
||||||
|
grid_disp.addWidget(set_btn, 0, 0, 1, 1)
|
||||||
off_btn = QtWidgets.QToolButton()
|
off_btn = QtWidgets.QToolButton()
|
||||||
off_btn.setText("Off")
|
off_btn.setText("Off")
|
||||||
off_btn.setToolTip("Switch off the output")
|
off_btn.setToolTip("Switch off the output")
|
||||||
set_grid.addWidget(off_btn, 0, 2, 1, 1)
|
grid_disp.addWidget(off_btn, 0, 1, 1, 1)
|
||||||
|
else:
|
||||||
|
grid_disp.addWidget(set_btn, 0, 0, 1, 2)
|
||||||
|
|
||||||
self.button_stack.addWidget(set_grid)
|
self.value_label = QtWidgets.QLabel()
|
||||||
|
self.value_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
|
||||||
|
grid_disp.addWidget(self.value_label, 0, 2, 1, 4)
|
||||||
|
|
||||||
# page 2: apply/cancel buttons
|
self.stack.addWidget(grid_disp)
|
||||||
apply_grid = LayoutWidget()
|
|
||||||
|
# page 2: edit data
|
||||||
|
grid_edit = LayoutWidget()
|
||||||
apply = QtWidgets.QToolButton()
|
apply = QtWidgets.QToolButton()
|
||||||
apply.setText("Apply")
|
apply.setText("Apply")
|
||||||
apply.setToolTip("Apply changes")
|
apply.setToolTip("Apply changes")
|
||||||
apply_grid.addWidget(apply, 0, 1, 1, 1)
|
grid_edit.addWidget(apply, 0, 0, 1, 1)
|
||||||
cancel = QtWidgets.QToolButton()
|
cancel = QtWidgets.QToolButton()
|
||||||
cancel.setText("Cancel")
|
cancel.setText("Cancel")
|
||||||
cancel.setToolTip("Cancel changes")
|
cancel.setToolTip("Cancel changes")
|
||||||
apply_grid.addWidget(cancel, 0, 2, 1, 1)
|
grid_edit.addWidget(cancel, 0, 1, 1, 1)
|
||||||
self.button_stack.addWidget(apply_grid)
|
grid_edit.layout.setContentsMargins(0, 0, 0, 0)
|
||||||
grid.addWidget(self.button_stack, 3, 1)
|
grid_edit.layout.setHorizontalSpacing(0)
|
||||||
|
grid_edit.layout.setVerticalSpacing(0)
|
||||||
|
self.value_edit = _CancellableLineEdit(self)
|
||||||
|
self.value_edit.setAlignment(QtCore.Qt.AlignRight)
|
||||||
|
grid_edit.addWidget(self.value_edit, 0, 2, 1, 4)
|
||||||
|
self.stack.addWidget(grid_edit)
|
||||||
|
|
||||||
grid.setRowStretch(1, 1)
|
grid.addWidget(self.stack, 0, 1, 1, 6)
|
||||||
grid.setRowStretch(2, 1)
|
|
||||||
grid.setRowStretch(3, 1)
|
unit = QtWidgets.QLabel("MHz")
|
||||||
|
unit.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
|
||||||
|
grid.addWidget(unit, 0, 7)
|
||||||
|
|
||||||
set_btn.clicked.connect(self.set_clicked)
|
set_btn.clicked.connect(self.set_clicked)
|
||||||
apply.clicked.connect(self.apply_changes)
|
apply.clicked.connect(self.apply_changes)
|
||||||
@ -249,8 +226,7 @@ class _DDSWidget(QtWidgets.QFrame):
|
|||||||
cancel.clicked.connect(cancel_changes)
|
cancel.clicked.connect(cancel_changes)
|
||||||
|
|
||||||
def set_page(self, page):
|
def set_page(self, page):
|
||||||
self.data_stack.setCurrentIndex(page)
|
self.stack.setCurrentIndex(page)
|
||||||
self.button_stack.setCurrentIndex(page)
|
|
||||||
|
|
||||||
def get_value(self):
|
def get_value(self):
|
||||||
return float(self.value_edit.text())
|
return float(self.value_edit.text())
|
||||||
|
Loading…
Reference in New Issue
Block a user