From 136d44d9db7905993f82ae975767ccdfa874583a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 1 Sep 2015 14:25:20 -0600 Subject: [PATCH] gui/moninj: display comments --- artiq/gui/moninj.py | 32 ++++++++++++++++++++++---------- examples/master/ddb.pyon | 9 ++++++--- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/artiq/gui/moninj.py b/artiq/gui/moninj.py index d1e8a0f3a..bd7e94214 100644 --- a/artiq/gui/moninj.py +++ b/artiq/gui/moninj.py @@ -23,7 +23,7 @@ _mode_enc = { 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.channel = channel self.force_out = force_out @@ -35,8 +35,9 @@ class _TTLWidget(QtGui.QFrame): grid = QtGui.QGridLayout() self.setLayout(grid) - label = QtGui.QLabel(name) + label = QtGui.QLabel(title) label.setAlignment(QtCore.Qt.AlignCenter) + label.setWordWrap(True) grid.addWidget(label, 1, 1) self._direction = QtGui.QLabel() @@ -77,6 +78,12 @@ class _TTLWidget(QtGui.QFrame): self._value.addAction(self._forcein_action) 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) def set_mode(self, mode): @@ -112,11 +119,8 @@ class _TTLWidget(QtGui.QFrame): class _DDSWidget(QtGui.QFrame): - def __init__(self, send_to_device, channel, sysclk, name): - self.send_to_device = send_to_device - self.channel = channel + def __init__(self, sysclk, title): self.sysclk = sysclk - self.name = name QtGui.QFrame.__init__(self) @@ -125,8 +129,9 @@ class _DDSWidget(QtGui.QFrame): grid = QtGui.QGridLayout() self.setLayout(grid) - label = QtGui.QLabel(name) + label = QtGui.QLabel(title) label.setAlignment(QtCore.Qt.AlignCenter) + label.setWordWrap(True) grid.addWidget(label, 1, 1) self._value = QtGui.QLabel() @@ -134,6 +139,10 @@ class _DDSWidget(QtGui.QFrame): self._value.setWordWrap(True) grid.addWidget(self._value, 2, 1, 6, 1) + grid.setRowStretch(1, 1) + grid.setRowStretch(2, 0) + grid.setRowStretch(3, 1) + self.set_value(0) def set_value(self, ftw): @@ -161,18 +170,20 @@ class _DeviceManager: return try: if v["type"] == "local": + title = k + if "comment" in v: + title += ": " + v["comment"] if v["module"] == "artiq.coredevice.ttl": channel = v["arguments"]["channel"] force_out = v["class"] == "TTLOut" self.ttl_widgets[channel] = _TTLWidget( - self.send_to_device, channel, force_out, k) + self.send_to_device, channel, force_out, title) self.ttl_cb() if (v["module"] == "artiq.coredevice.dds" and v["class"] in {"AD9858", "AD9914"}): channel = v["arguments"]["channel"] sysclk = v["arguments"]["sysclk"] - self.dds_widgets[channel] = _DDSWidget( - self.send_to_device, channel, sysclk, k) + self.dds_widgets[channel] = _DDSWidget(sysclk, title) self.dds_cb() except KeyError: pass @@ -209,6 +220,7 @@ class _MonInjDock(dockarea.Dock): w = self.grid.itemAt(0) for i, (_, w) in enumerate(sorted(widgets, key=itemgetter(0))): self.grid.addWidget(w, i // 4, i % 4) + self.grid.setColumnStretch(i % 4, 1) class MonInj(TaskObject): diff --git a/examples/master/ddb.pyon b/examples/master/ddb.pyon index 00e823a28..cafe5e538 100644 --- a/examples/master/ddb.pyon +++ b/examples/master/ddb.pyon @@ -29,13 +29,15 @@ "type": "local", "module": "artiq.coredevice.ttl", "class": "TTLOut", - "arguments": {"channel": 2} + "arguments": {"channel": 2}, + "comment": "This is a fairly long comment to test word wrapping in GUI." }, "ttl1": { "type": "local", "module": "artiq.coredevice.ttl", "class": "TTLOut", - "arguments": {"channel": 3} + "arguments": {"channel": 3}, + "comment": "Hello World" }, "ttl2": { "type": "local", @@ -72,7 +74,8 @@ "type": "local", "module": "artiq.coredevice.dds", "class": "AD9858", - "arguments": {"sysclk": 1e9, "channel": 0} + "arguments": {"sysclk": 1e9, "channel": 0}, + "comment": "Comments work in DDS panel as well" }, "dds1": { "type": "local",