forked from M-Labs/artiq
gui: save display state
This commit is contained in:
parent
a64766a10d
commit
8ad88438c7
|
@ -82,6 +82,7 @@ def main():
|
||||||
atexit.register(lambda: loop.run_until_complete(d_explorer.sub_close()))
|
atexit.register(lambda: loop.run_until_complete(d_explorer.sub_close()))
|
||||||
|
|
||||||
d_results = ResultsDock(win, area)
|
d_results = ResultsDock(win, area)
|
||||||
|
smgr.register(d_results)
|
||||||
loop.run_until_complete(d_results.sub_connect(
|
loop.run_until_complete(d_results.sub_connect(
|
||||||
args.server, args.port_notify))
|
args.server, args.port_notify))
|
||||||
atexit.register(lambda: loop.run_until_complete(d_results.sub_close()))
|
atexit.register(lambda: loop.run_until_complete(d_results.sub_close()))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
import logging
|
||||||
|
|
||||||
from quamash import QtGui, QtCore
|
from quamash import QtGui, QtCore
|
||||||
from pyqtgraph import dockarea
|
from pyqtgraph import dockarea
|
||||||
|
@ -11,6 +12,9 @@ from artiq.gui.tools import DictSyncModel, short_format
|
||||||
from artiq.gui.displays import *
|
from artiq.gui.displays import *
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ResultsModel(DictSyncModel):
|
class ResultsModel(DictSyncModel):
|
||||||
def __init__(self, parent, init):
|
def __init__(self, parent, init):
|
||||||
DictSyncModel.__init__(self, ["Result", "Value"],
|
DictSyncModel.__init__(self, ["Result", "Value"],
|
||||||
|
@ -28,6 +32,12 @@ class ResultsModel(DictSyncModel):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
|
||||||
|
def _get_display_type_name(display_cls):
|
||||||
|
for name, (_, cls) in display_types.items():
|
||||||
|
if cls is display_cls:
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
class ResultsDock(dockarea.Dock):
|
class ResultsDock(dockarea.Dock):
|
||||||
def __init__(self, dialog_parent, dock_area):
|
def __init__(self, dialog_parent, dock_area):
|
||||||
dockarea.Dock.__init__(self, "Results", size=(1500, 500))
|
dockarea.Dock.__init__(self, "Results", size=(1500, 500))
|
||||||
|
@ -110,3 +120,20 @@ class ResultsDock(dockarea.Dock):
|
||||||
dsp.sigClosed.connect(on_close)
|
dsp.sigClosed.connect(on_close)
|
||||||
self.dock_area.addDock(dsp)
|
self.dock_area.addDock(dsp)
|
||||||
self.dock_area.floatDock(dsp)
|
self.dock_area.floatDock(dsp)
|
||||||
|
|
||||||
|
def save_state(self):
|
||||||
|
r = dict()
|
||||||
|
for name, display in self.displays.items():
|
||||||
|
r[name] = {
|
||||||
|
"ty": _get_display_type_name(type(display)),
|
||||||
|
"settings": display.settings
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
|
||||||
|
def restore_state(self, state):
|
||||||
|
for name, desc in state.items():
|
||||||
|
try:
|
||||||
|
self.create_display(desc["ty"], None, name, desc["settings"])
|
||||||
|
except:
|
||||||
|
logger.warning("Failed to create display '%s'", name,
|
||||||
|
exc_info=True)
|
||||||
|
|
Loading…
Reference in New Issue