gui/console: use network clients directly

This commit is contained in:
Sebastien Bourdeauducq 2015-11-11 17:02:51 +08:00
parent 4166f4e928
commit 62c0eb85b1
3 changed files with 21 additions and 15 deletions

View File

@ -120,14 +120,8 @@ def main():
d_log = log.LogDock(sub_clients["log"]) d_log = log.LogDock(sub_clients["log"])
smgr.register(d_log) smgr.register(d_log)
def _set_dataset(k, v): d_console = console.ConsoleDock(sub_clients["datasets"],
asyncio.ensure_future(rpc_clients["dataset_db"].set(k, v)) rpc_clients["dataset_db"])
def _del_dataset(k):
asyncio.ensure_future(rpc_clients["dataset_db"].delete(k))
d_console = console.ConsoleDock(
d_datasets.get_dataset,
_set_dataset,
_del_dataset)
area.addDock(d_console, "bottom") area.addDock(d_console, "bottom")
area.addDock(d_log, "above", d_console) area.addDock(d_log, "above", d_console)

View File

@ -1,3 +1,5 @@
import asyncio
from pyqtgraph import console, dockarea from pyqtgraph import console, dockarea
@ -12,12 +14,25 @@ The following functions are available:
""" """
class ConsoleDock(dockarea.Dock): class ConsoleDock(dockarea.Dock):
def __init__(self, get_dataset, set_dataset, del_dataset): def __init__(self, dataset_sub, dataset_ctl):
dockarea.Dock.__init__(self, "Console", size=(1000, 300)) dockarea.Dock.__init__(self, "Console", size=(1000, 300))
self.dataset_sub = dataset_sub
self.dataset_ctl = dataset_ctl
ns = { ns = {
"get_dataset": get_dataset, "get_dataset": self.get_dataset,
"set_dataset": set_dataset, "set_dataset": self.set_dataset,
"del_dataset": del_dataset "del_dataset": self.del_dataset
} }
c = console.ConsoleWidget(namespace=ns, text=_help) c = console.ConsoleWidget(namespace=ns, text=_help)
self.addWidget(c) 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))

View File

@ -84,9 +84,6 @@ class DatasetsDock(dockarea.Dock):
self.table_model_filter.setFilterFixedString( self.table_model_filter.setFilterFixedString(
self.search.displayText()) self.search.displayText())
def get_dataset(self, key):
return self.table_model.backing_store[key][1]
def set_model(self, model): def set_model(self, model):
self.table_model = model self.table_model = model
self.table_model_filter = QSortFilterProxyModel() self.table_model_filter = QSortFilterProxyModel()