mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-19 00:16:29 +08:00
dashboard: pack moninj widgets (#603)
This commit is contained in:
parent
9d58b4516c
commit
8ec73cb9ec
@ -23,35 +23,26 @@ _mode_enc = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _MoninjWidget(QtWidgets.QFrame):
|
class _TTLWidget(QtWidgets.QFrame):
|
||||||
def __init__(self):
|
|
||||||
QtWidgets.QFrame.__init__(self)
|
|
||||||
qfm = QtGui.QFontMetrics(self.font())
|
|
||||||
self._size = QtCore.QSize(
|
|
||||||
18*qfm.averageCharWidth(),
|
|
||||||
6*qfm.lineSpacing())
|
|
||||||
self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
|
|
||||||
|
|
||||||
self.setFrameShape(QtWidgets.QFrame.Box)
|
|
||||||
self.setFrameShadow(QtWidgets.QFrame.Raised)
|
|
||||||
|
|
||||||
def sizeHint(self):
|
|
||||||
return self._size
|
|
||||||
|
|
||||||
|
|
||||||
class _TTLWidget(_MoninjWidget):
|
|
||||||
def __init__(self, channel, send_to_device, force_out, title):
|
def __init__(self, channel, send_to_device, force_out, title):
|
||||||
|
QtWidgets.QFrame.__init__(self)
|
||||||
|
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.send_to_device = send_to_device
|
self.send_to_device = send_to_device
|
||||||
self.force_out = force_out
|
self.force_out = force_out
|
||||||
|
|
||||||
_MoninjWidget.__init__(self)
|
self.setFrameShape(QtWidgets.QFrame.Box)
|
||||||
|
self.setFrameShadow(QtWidgets.QFrame.Raised)
|
||||||
|
|
||||||
grid = QtWidgets.QGridLayout()
|
grid = QtWidgets.QGridLayout()
|
||||||
|
grid.setContentsMargins(0, 0, 0, 0)
|
||||||
|
grid.setHorizontalSpacing(0)
|
||||||
|
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)
|
||||||
label.setWordWrap(True)
|
label.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
|
||||||
|
QtWidgets.QSizePolicy.Preferred)
|
||||||
grid.addWidget(label, 1, 1)
|
grid.addWidget(label, 1, 1)
|
||||||
|
|
||||||
self.stack = QtWidgets.QStackedWidget()
|
self.stack = QtWidgets.QStackedWidget()
|
||||||
@ -62,9 +53,18 @@ class _TTLWidget(_MoninjWidget):
|
|||||||
self.stack.addWidget(self.direction)
|
self.stack.addWidget(self.direction)
|
||||||
|
|
||||||
grid_cb = LayoutWidget()
|
grid_cb = LayoutWidget()
|
||||||
self.override = QtWidgets.QCheckBox("Override")
|
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_cb.addWidget(self.override, 3, 1)
|
||||||
self.level = QtWidgets.QCheckBox("Level")
|
self.level = QtWidgets.QToolButton()
|
||||||
|
self.level.setText("LVL")
|
||||||
|
self.level.setCheckable(True)
|
||||||
|
self.level.setToolTip("Level")
|
||||||
grid_cb.addWidget(self.level, 3, 2)
|
grid_cb.addWidget(self.level, 3, 2)
|
||||||
self.stack.addWidget(grid_cb)
|
self.stack.addWidget(grid_cb)
|
||||||
|
|
||||||
@ -78,19 +78,19 @@ class _TTLWidget(_MoninjWidget):
|
|||||||
grid.setRowStretch(4, 1)
|
grid.setRowStretch(4, 1)
|
||||||
|
|
||||||
self.programmatic_change = False
|
self.programmatic_change = False
|
||||||
self.override.stateChanged.connect(self.override_toggled)
|
self.override.clicked.connect(self.override_toggled)
|
||||||
self.level.stateChanged.connect(self.level_toggled)
|
self.level.clicked.connect(self.level_toggled)
|
||||||
|
|
||||||
self.set_value(0, False, False)
|
self.set_value(0, False, False)
|
||||||
|
|
||||||
def enterEvent(self, event):
|
def enterEvent(self, event):
|
||||||
self.stack.setCurrentIndex(1)
|
self.stack.setCurrentIndex(1)
|
||||||
_MoninjWidget.enterEvent(self, event)
|
QtWidgets.QFrame.enterEvent(self, event)
|
||||||
|
|
||||||
def leaveEvent(self, event):
|
def leaveEvent(self, event):
|
||||||
if not self.override.isChecked():
|
if not self.override.isChecked():
|
||||||
self.stack.setCurrentIndex(0)
|
self.stack.setCurrentIndex(0)
|
||||||
_MoninjWidget.leaveEvent(self, event)
|
QtWidgets.QFrame.leaveEvent(self, event)
|
||||||
|
|
||||||
def override_toggled(self, override):
|
def override_toggled(self, override):
|
||||||
if self.programmatic_change:
|
if self.programmatic_change:
|
||||||
@ -125,11 +125,11 @@ class _TTLWidget(_MoninjWidget):
|
|||||||
color = " color=\"red\""
|
color = " color=\"red\""
|
||||||
else:
|
else:
|
||||||
color = ""
|
color = ""
|
||||||
self.value.setText("<font size=\"9\"{}>{}</font>".format(
|
self.value.setText("<font size=\"5\"{}>{}</font>".format(
|
||||||
color, value_s))
|
color, value_s))
|
||||||
oe = oe or self.force_out
|
oe = oe or self.force_out
|
||||||
direction = "OUT" if oe else "IN"
|
direction = "OUT" if oe else "IN"
|
||||||
self.direction.setText("<font size=\"1\">" + direction + "</font>")
|
self.direction.setText("<font size=\"2\">" + direction + "</font>")
|
||||||
|
|
||||||
self.programmatic_change = True
|
self.programmatic_change = True
|
||||||
try:
|
try:
|
||||||
@ -144,24 +144,30 @@ class _TTLWidget(_MoninjWidget):
|
|||||||
return self.channel
|
return self.channel
|
||||||
|
|
||||||
|
|
||||||
class _DDSWidget(_MoninjWidget):
|
class _DDSWidget(QtWidgets.QFrame):
|
||||||
def __init__(self, bus_channel, channel, sysclk, title):
|
def __init__(self, bus_channel, channel, sysclk, title):
|
||||||
|
QtWidgets.QFrame.__init__(self)
|
||||||
|
|
||||||
self.bus_channel = bus_channel
|
self.bus_channel = bus_channel
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.sysclk = sysclk
|
self.sysclk = sysclk
|
||||||
|
|
||||||
_MoninjWidget.__init__(self)
|
self.setFrameShape(QtWidgets.QFrame.Box)
|
||||||
|
self.setFrameShadow(QtWidgets.QFrame.Raised)
|
||||||
|
|
||||||
grid = QtWidgets.QGridLayout()
|
grid = QtWidgets.QGridLayout()
|
||||||
|
grid.setContentsMargins(0, 0, 0, 0)
|
||||||
|
grid.setHorizontalSpacing(0)
|
||||||
|
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)
|
||||||
label.setWordWrap(True)
|
label.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
|
||||||
|
QtWidgets.QSizePolicy.Preferred)
|
||||||
grid.addWidget(label, 1, 1)
|
grid.addWidget(label, 1, 1)
|
||||||
|
|
||||||
self.value = QtWidgets.QLabel()
|
self.value = QtWidgets.QLabel()
|
||||||
self.value.setAlignment(QtCore.Qt.AlignCenter)
|
self.value.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
self.value.setWordWrap(True)
|
|
||||||
grid.addWidget(self.value, 2, 1, 6, 1)
|
grid.addWidget(self.value, 2, 1, 6, 1)
|
||||||
|
|
||||||
grid.setRowStretch(1, 1)
|
grid.setRowStretch(1, 1)
|
||||||
@ -172,7 +178,7 @@ class _DDSWidget(_MoninjWidget):
|
|||||||
|
|
||||||
def set_value(self, ftw):
|
def set_value(self, ftw):
|
||||||
frequency = ftw*self.sysclk()/2**32
|
frequency = ftw*self.sysclk()/2**32
|
||||||
self.value.setText("<font size=\"5\">{:.7f} MHz</font>"
|
self.value.setText("<font size=\"4\">{:.7f}</font><font size=\"2\"> MHz</font>"
|
||||||
.format(frequency/1e6))
|
.format(frequency/1e6))
|
||||||
|
|
||||||
def sort_key(self):
|
def sort_key(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user