From de73bd19982b17d3024eb567aad1961b5ddedc80 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 30 Apr 2016 10:46:56 +0800 Subject: [PATCH] gui/moninj: sort by channel. Closes #413 --- artiq/dashboard/moninj.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/artiq/dashboard/moninj.py b/artiq/dashboard/moninj.py index fb793a9eb..61a6cc407 100644 --- a/artiq/dashboard/moninj.py +++ b/artiq/dashboard/moninj.py @@ -3,7 +3,6 @@ import threading import logging import socket import struct -from operator import itemgetter from PyQt5 import QtCore, QtWidgets, QtGui @@ -141,6 +140,9 @@ class _TTLWidget(_MoninjWidget): finally: self.programmatic_change = False + def sort_key(self): + return self.channel + class _DDSWidget(_MoninjWidget): def __init__(self, bus_channel, channel, sysclk, title): @@ -173,6 +175,9 @@ class _DDSWidget(_MoninjWidget): self.value.setText("{:.7f} MHz" .format(frequency/1e6)) + def sort_key(self): + return (self.bus_channel, self.channel) + class _DeviceManager: def __init__(self, send_to_device, init): @@ -260,7 +265,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)