gui/moninj: display comments

This commit is contained in:
Sebastien Bourdeauducq 2015-09-01 14:25:20 -06:00
parent 6dba0e94c5
commit 136d44d9db
2 changed files with 28 additions and 13 deletions

View File

@ -23,7 +23,7 @@ _mode_enc = {
class _TTLWidget(QtGui.QFrame): class _TTLWidget(QtGui.QFrame):
def __init__(self, send_to_device, channel, force_out, name): def __init__(self, send_to_device, channel, force_out, title):
self.send_to_device = send_to_device self.send_to_device = send_to_device
self.channel = channel self.channel = channel
self.force_out = force_out self.force_out = force_out
@ -35,8 +35,9 @@ class _TTLWidget(QtGui.QFrame):
grid = QtGui.QGridLayout() grid = QtGui.QGridLayout()
self.setLayout(grid) self.setLayout(grid)
label = QtGui.QLabel(name) label = QtGui.QLabel(title)
label.setAlignment(QtCore.Qt.AlignCenter) label.setAlignment(QtCore.Qt.AlignCenter)
label.setWordWrap(True)
grid.addWidget(label, 1, 1) grid.addWidget(label, 1, 1)
self._direction = QtGui.QLabel() self._direction = QtGui.QLabel()
@ -77,6 +78,12 @@ class _TTLWidget(QtGui.QFrame):
self._value.addAction(self._forcein_action) self._value.addAction(self._forcein_action)
self._forcein_action.triggered.connect(lambda: self.set_mode("in")) self._forcein_action.triggered.connect(lambda: self.set_mode("in"))
grid.setRowStretch(1, 1)
grid.setRowStretch(2, 0)
grid.setRowStretch(3, 0)
grid.setRowStretch(4, 0)
grid.setRowStretch(5, 1)
self.set_value(0, False, False) self.set_value(0, False, False)
def set_mode(self, mode): def set_mode(self, mode):
@ -112,11 +119,8 @@ class _TTLWidget(QtGui.QFrame):
class _DDSWidget(QtGui.QFrame): class _DDSWidget(QtGui.QFrame):
def __init__(self, send_to_device, channel, sysclk, name): def __init__(self, sysclk, title):
self.send_to_device = send_to_device
self.channel = channel
self.sysclk = sysclk self.sysclk = sysclk
self.name = name
QtGui.QFrame.__init__(self) QtGui.QFrame.__init__(self)
@ -125,8 +129,9 @@ class _DDSWidget(QtGui.QFrame):
grid = QtGui.QGridLayout() grid = QtGui.QGridLayout()
self.setLayout(grid) self.setLayout(grid)
label = QtGui.QLabel(name) label = QtGui.QLabel(title)
label.setAlignment(QtCore.Qt.AlignCenter) label.setAlignment(QtCore.Qt.AlignCenter)
label.setWordWrap(True)
grid.addWidget(label, 1, 1) grid.addWidget(label, 1, 1)
self._value = QtGui.QLabel() self._value = QtGui.QLabel()
@ -134,6 +139,10 @@ class _DDSWidget(QtGui.QFrame):
self._value.setWordWrap(True) 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(2, 0)
grid.setRowStretch(3, 1)
self.set_value(0) self.set_value(0)
def set_value(self, ftw): def set_value(self, ftw):
@ -161,18 +170,20 @@ class _DeviceManager:
return return
try: try:
if v["type"] == "local": if v["type"] == "local":
title = k
if "comment" in v:
title += ": " + v["comment"]
if v["module"] == "artiq.coredevice.ttl": if v["module"] == "artiq.coredevice.ttl":
channel = v["arguments"]["channel"] channel = v["arguments"]["channel"]
force_out = v["class"] == "TTLOut" force_out = v["class"] == "TTLOut"
self.ttl_widgets[channel] = _TTLWidget( self.ttl_widgets[channel] = _TTLWidget(
self.send_to_device, channel, force_out, k) self.send_to_device, channel, force_out, title)
self.ttl_cb() self.ttl_cb()
if (v["module"] == "artiq.coredevice.dds" if (v["module"] == "artiq.coredevice.dds"
and v["class"] in {"AD9858", "AD9914"}): and v["class"] in {"AD9858", "AD9914"}):
channel = v["arguments"]["channel"] channel = v["arguments"]["channel"]
sysclk = v["arguments"]["sysclk"] sysclk = v["arguments"]["sysclk"]
self.dds_widgets[channel] = _DDSWidget( self.dds_widgets[channel] = _DDSWidget(sysclk, title)
self.send_to_device, channel, sysclk, k)
self.dds_cb() self.dds_cb()
except KeyError: except KeyError:
pass pass
@ -209,6 +220,7 @@ class _MonInjDock(dockarea.Dock):
w = self.grid.itemAt(0) w = self.grid.itemAt(0)
for i, (_, w) in enumerate(sorted(widgets, key=itemgetter(0))): for i, (_, w) in enumerate(sorted(widgets, key=itemgetter(0))):
self.grid.addWidget(w, i // 4, i % 4) self.grid.addWidget(w, i // 4, i % 4)
self.grid.setColumnStretch(i % 4, 1)
class MonInj(TaskObject): class MonInj(TaskObject):

View File

@ -29,13 +29,15 @@
"type": "local", "type": "local",
"module": "artiq.coredevice.ttl", "module": "artiq.coredevice.ttl",
"class": "TTLOut", "class": "TTLOut",
"arguments": {"channel": 2} "arguments": {"channel": 2},
"comment": "This is a fairly long comment to test word wrapping in GUI."
}, },
"ttl1": { "ttl1": {
"type": "local", "type": "local",
"module": "artiq.coredevice.ttl", "module": "artiq.coredevice.ttl",
"class": "TTLOut", "class": "TTLOut",
"arguments": {"channel": 3} "arguments": {"channel": 3},
"comment": "Hello World"
}, },
"ttl2": { "ttl2": {
"type": "local", "type": "local",
@ -72,7 +74,8 @@
"type": "local", "type": "local",
"module": "artiq.coredevice.dds", "module": "artiq.coredevice.dds",
"class": "AD9858", "class": "AD9858",
"arguments": {"sysclk": 1e9, "channel": 0} "arguments": {"sysclk": 1e9, "channel": 0},
"comment": "Comments work in DDS panel as well"
}, },
"dds1": { "dds1": {
"type": "local", "type": "local",