2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

gui: save display state

This commit is contained in:
Sebastien Bourdeauducq 2015-08-01 19:37:16 +08:00
parent a64766a10d
commit 8ad88438c7
2 changed files with 28 additions and 0 deletions

View File

@ -82,6 +82,7 @@ def main():
atexit.register(lambda: loop.run_until_complete(d_explorer.sub_close()))
d_results = ResultsDock(win, area)
smgr.register(d_results)
loop.run_until_complete(d_results.sub_connect(
args.server, args.port_notify))
atexit.register(lambda: loop.run_until_complete(d_results.sub_close()))

View File

@ -1,6 +1,7 @@
import asyncio
from collections import OrderedDict
from functools import partial
import logging
from quamash import QtGui, QtCore
from pyqtgraph import dockarea
@ -11,6 +12,9 @@ from artiq.gui.tools import DictSyncModel, short_format
from artiq.gui.displays import *
logger = logging.getLogger(__name__)
class ResultsModel(DictSyncModel):
def __init__(self, parent, init):
DictSyncModel.__init__(self, ["Result", "Value"],
@ -28,6 +32,12 @@ class ResultsModel(DictSyncModel):
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):
def __init__(self, dialog_parent, dock_area):
dockarea.Dock.__init__(self, "Results", size=(1500, 500))
@ -110,3 +120,20 @@ class ResultsDock(dockarea.Dock):
dsp.sigClosed.connect(on_close)
self.dock_area.addDock(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)