diff --git a/artiq/gui/moninj.py b/artiq/gui/moninj.py index aabfea715..c0e662ea8 100644 --- a/artiq/gui/moninj.py +++ b/artiq/gui/moninj.py @@ -3,7 +3,6 @@ import threading import logging import socket import struct -from operator import itemgetter from PyQt5 import QtCore, QtWidgets, QtGui @@ -131,6 +130,9 @@ class _TTLWidget(_MoninjWidget): else: self._expctl_action.setChecked(True) + def sort_key(self): + return self.channel + class _DDSWidget(_MoninjWidget): def __init__(self, bus_channel, channel, sysclk, title): @@ -163,6 +165,9 @@ class _DDSWidget(_MoninjWidget): self._value.setText("{:.7f} MHz" .format(float(frequency)/1e6)) + def sort_key(self): + return (self.bus_channel, self.channel) + class _DeviceManager: def __init__(self, send_to_device, init): @@ -248,7 +253,7 @@ class _MonInjDock(QtWidgets.QDockWidget): grid_widget = QtWidgets.QWidget() grid_widget.setLayout(grid) - for _, w in sorted(widgets, key=itemgetter(0)): + for _, w in sorted(widgets, key=lambda i: i[1].sort_key()): grid.addWidget(w) scroll_area.setWidgetResizable(True)