forked from M-Labs/artiq
moninj: merge into single layout
This commit is contained in:
parent
baa58343ac
commit
c6194eb430
|
@ -739,38 +739,30 @@ class _DeviceManager:
|
||||||
await self.mi_connection.close()
|
await self.mi_connection.close()
|
||||||
|
|
||||||
|
|
||||||
class _MonInjDock(QtWidgets.QDockWidget):
|
class MonInjDock(QtWidgets.QDockWidget):
|
||||||
def __init__(self, name):
|
def __init__(self, schedule_ctl):
|
||||||
QtWidgets.QDockWidget.__init__(self, name)
|
QtWidgets.QDockWidget.__init__(self, "MonInj")
|
||||||
self.setObjectName(name)
|
self.setObjectName("MonInj")
|
||||||
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
|
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
|
||||||
QtWidgets.QDockWidget.DockWidgetFloatable)
|
QtWidgets.QDockWidget.DockWidgetFloatable)
|
||||||
|
|
||||||
def layout_widgets(self, widgets):
|
|
||||||
scroll_area = QtWidgets.QScrollArea()
|
scroll_area = QtWidgets.QScrollArea()
|
||||||
|
scroll_area.setWidgetResizable(True)
|
||||||
self.setWidget(scroll_area)
|
self.setWidget(scroll_area)
|
||||||
|
|
||||||
grid = FlowLayout()
|
self.grid = FlowLayout()
|
||||||
grid_widget = QtWidgets.QWidget()
|
grid_widget = QtWidgets.QWidget()
|
||||||
grid_widget.setLayout(grid)
|
grid_widget.setLayout(self.grid)
|
||||||
|
|
||||||
for widget in sorted(widgets, key=lambda w: w.sort_key()):
|
|
||||||
grid.addWidget(widget)
|
|
||||||
|
|
||||||
scroll_area.setWidgetResizable(True)
|
|
||||||
scroll_area.setWidget(grid_widget)
|
scroll_area.setWidget(grid_widget)
|
||||||
|
|
||||||
|
|
||||||
class MonInj:
|
|
||||||
def __init__(self, schedule_ctl):
|
|
||||||
self.ttl_dock = _MonInjDock("TTL")
|
|
||||||
self.dds_dock = _MonInjDock("DDS")
|
|
||||||
self.dac_dock = _MonInjDock("DAC")
|
|
||||||
|
|
||||||
self.dm = _DeviceManager(schedule_ctl)
|
self.dm = _DeviceManager(schedule_ctl)
|
||||||
self.dm.ttl_cb = lambda: self.ttl_dock.layout_widgets(self.dm.ttl_widgets.values())
|
self.dm.ttl_cb = lambda: self.layout_widgets(self.dm.ttl_widgets.values())
|
||||||
self.dm.dds_cb = lambda: self.dds_dock.layout_widgets(self.dm.dds_widgets.values())
|
self.dm.dds_cb = lambda: self.layout_widgets(self.dm.dds_widgets.values())
|
||||||
self.dm.dac_cb = lambda: self.dac_dock.layout_widgets(self.dm.dac_widgets.values())
|
self.dm.dac_cb = lambda: self.layout_widgets(self.dm.dac_widgets.values())
|
||||||
|
|
||||||
|
def layout_widgets(self, widgets):
|
||||||
|
for widget in sorted(widgets, key=lambda w: w.sort_key()):
|
||||||
|
self.grid.addWidget(widget)
|
||||||
|
|
||||||
async def stop(self):
|
async def stop(self):
|
||||||
if self.dm is not None:
|
if self.dm is not None:
|
||||||
|
|
|
@ -226,8 +226,8 @@ def main():
|
||||||
smgr.register(d_applets)
|
smgr.register(d_applets)
|
||||||
broadcast_clients["ccb"].notify_cbs.append(d_applets.ccb_notify)
|
broadcast_clients["ccb"].notify_cbs.append(d_applets.ccb_notify)
|
||||||
|
|
||||||
d_ttl_dds = moninj.MonInj(rpc_clients["schedule"])
|
d_moninj = moninj.MonInjDock(rpc_clients["schedule"])
|
||||||
atexit_register_coroutine(d_ttl_dds.stop, loop=loop)
|
atexit_register_coroutine(d_moninj.stop, loop=loop)
|
||||||
|
|
||||||
d_waveform = waveform.WaveformDock(
|
d_waveform = waveform.WaveformDock(
|
||||||
args.analyzer_proxy_timeout,
|
args.analyzer_proxy_timeout,
|
||||||
|
@ -237,10 +237,10 @@ def main():
|
||||||
atexit_register_coroutine(d_waveform.stop, loop=loop)
|
atexit_register_coroutine(d_waveform.stop, loop=loop)
|
||||||
|
|
||||||
def init_cbs(ddb):
|
def init_cbs(ddb):
|
||||||
d_ttl_dds.dm.init_ddb(ddb)
|
d_moninj.dm.init_ddb(ddb)
|
||||||
d_waveform.init_ddb(ddb)
|
d_waveform.init_ddb(ddb)
|
||||||
return ddb
|
return ddb
|
||||||
devices_sub = Subscriber("devices", init_cbs, [d_ttl_dds.dm.notify_ddb, d_waveform.notify_ddb])
|
devices_sub = Subscriber("devices", init_cbs, [d_moninj.dm.notify_ddb, d_waveform.notify_ddb])
|
||||||
loop.run_until_complete(devices_sub.connect(args.server, args.port_notify))
|
loop.run_until_complete(devices_sub.connect(args.server, args.port_notify))
|
||||||
atexit_register_coroutine(devices_sub.close, loop=loop)
|
atexit_register_coroutine(devices_sub.close, loop=loop)
|
||||||
|
|
||||||
|
@ -260,8 +260,7 @@ def main():
|
||||||
|
|
||||||
# lay out docks
|
# lay out docks
|
||||||
right_docks = [
|
right_docks = [
|
||||||
d_explorer, d_shortcuts,
|
d_explorer, d_shortcuts, d_moninj,
|
||||||
d_ttl_dds.ttl_dock, d_ttl_dds.dds_dock, d_ttl_dds.dac_dock,
|
|
||||||
d_datasets, d_applets, d_waveform, d_interactive_args
|
d_datasets, d_applets, d_waveform, d_interactive_args
|
||||||
]
|
]
|
||||||
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, right_docks[0])
|
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, right_docks[0])
|
||||||
|
@ -280,8 +279,7 @@ def main():
|
||||||
atexit_register_coroutine(smgr.stop, loop=loop)
|
atexit_register_coroutine(smgr.stop, loop=loop)
|
||||||
|
|
||||||
# work around for https://github.com/m-labs/artiq/issues/1307
|
# work around for https://github.com/m-labs/artiq/issues/1307
|
||||||
d_ttl_dds.ttl_dock.show()
|
d_moninj.show()
|
||||||
d_ttl_dds.dds_dock.show()
|
|
||||||
|
|
||||||
# create first log dock if not already in state
|
# create first log dock if not already in state
|
||||||
d_log0 = logmgr.first_log_dock()
|
d_log0 = logmgr.first_log_dock()
|
||||||
|
|
Loading…
Reference in New Issue