forked from M-Labs/artiq
1
0
Fork 0

gui/moninj: sort by channel. Closes #413

This commit is contained in:
Sebastien Bourdeauducq 2016-04-30 10:46:56 +08:00
parent b05e3f42e9
commit 06268d182f
1 changed files with 7 additions and 2 deletions

View File

@ -3,7 +3,6 @@ import threading
import logging import logging
import socket import socket
import struct import struct
from operator import itemgetter
from PyQt5 import QtCore, QtWidgets, QtGui from PyQt5 import QtCore, QtWidgets, QtGui
@ -131,6 +130,9 @@ class _TTLWidget(_MoninjWidget):
else: else:
self._expctl_action.setChecked(True) self._expctl_action.setChecked(True)
def sort_key(self):
return self.channel
class _DDSWidget(_MoninjWidget): class _DDSWidget(_MoninjWidget):
def __init__(self, bus_channel, channel, sysclk, title): def __init__(self, bus_channel, channel, sysclk, title):
@ -163,6 +165,9 @@ class _DDSWidget(_MoninjWidget):
self._value.setText("<font size=\"6\">{:.7f} MHz</font>" self._value.setText("<font size=\"6\">{:.7f} MHz</font>"
.format(float(frequency)/1e6)) .format(float(frequency)/1e6))
def sort_key(self):
return (self.bus_channel, self.channel)
class _DeviceManager: class _DeviceManager:
def __init__(self, send_to_device, init): def __init__(self, send_to_device, init):
@ -248,7 +253,7 @@ class _MonInjDock(QtWidgets.QDockWidget):
grid_widget = QtWidgets.QWidget() grid_widget = QtWidgets.QWidget()
grid_widget.setLayout(grid) 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) grid.addWidget(w)
scroll_area.setWidgetResizable(True) scroll_area.setWidgetResizable(True)