artiq/artiq/gui/console.py

41 lines
1.2 KiB
Python
Raw Normal View History

import asyncio
2015-12-11 00:20:20 +08:00
from quamash import QtCore
2015-07-25 00:36:16 +08:00
from pyqtgraph import console, dockarea
_help = """
2015-07-25 12:01:47 +08:00
This is an interactive Python console.
2015-07-25 00:36:16 +08:00
The following functions are available:
get_dataset(key)
set_dataset(key, value, persist=False) [asynchronous update]
del_dataset(key) [asynchronous update]
2015-07-25 00:36:16 +08:00
"""
class ConsoleDock(dockarea.Dock):
def __init__(self, dataset_sub, dataset_ctl):
2015-12-11 00:20:20 +08:00
dockarea.Dock.__init__(self, "Console")
self.setMinimumSize(QtCore.QSize(850, 300))
self.dataset_sub = dataset_sub
self.dataset_ctl = dataset_ctl
2015-07-25 00:36:16 +08:00
ns = {
"get_dataset": self.get_dataset,
"set_dataset": self.set_dataset,
"del_dataset": self.del_dataset
2015-07-25 00:36:16 +08:00
}
c = console.ConsoleWidget(namespace=ns, text=_help)
self.addWidget(c)
def get_dataset(self, k):
if self.dataset_sub.model is None:
raise IOError("Datasets not available yet")
return self.dataset_sub.model.backing_store[k][1]
def set_dataset(self, k, v):
asyncio.ensure_future(self.dataset_ctl.set(k, v))
def del_dataset(self, k):
asyncio.ensure_future(self.dataset_ctl.delete(k))