mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
gui: support experiment cancellation
This commit is contained in:
parent
ae4615281f
commit
5fb86af3a4
@ -73,7 +73,7 @@ def main():
|
|||||||
d_log = LogDock()
|
d_log = LogDock()
|
||||||
area.addDock(d_log, "bottom")
|
area.addDock(d_log, "bottom")
|
||||||
|
|
||||||
d_schedule = ScheduleDock()
|
d_schedule = ScheduleDock(schedule_ctl)
|
||||||
area.addDock(d_schedule, "above", d_log)
|
area.addDock(d_schedule, "above", d_log)
|
||||||
loop.run_until_complete(d_schedule.sub_connect(
|
loop.run_until_complete(d_schedule.sub_connect(
|
||||||
args.server, args.port_notify))
|
args.server, args.port_notify))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from quamash import QtGui
|
from quamash import QtGui, QtCore
|
||||||
from pyqtgraph import dockarea
|
from pyqtgraph import dockarea
|
||||||
|
|
||||||
from artiq.protocols.sync_struct import Subscriber
|
from artiq.protocols.sync_struct import Subscriber
|
||||||
@ -49,13 +49,20 @@ class _ScheduleModel(DictSyncModel):
|
|||||||
|
|
||||||
|
|
||||||
class ScheduleDock(dockarea.Dock):
|
class ScheduleDock(dockarea.Dock):
|
||||||
def __init__(self):
|
def __init__(self, schedule_ctl):
|
||||||
dockarea.Dock.__init__(self, "Schedule", size=(1000, 300))
|
dockarea.Dock.__init__(self, "Schedule", size=(1000, 300))
|
||||||
|
|
||||||
|
self.schedule_ctl = schedule_ctl
|
||||||
|
|
||||||
self.table = QtGui.QTableView()
|
self.table = QtGui.QTableView()
|
||||||
self.table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
self.table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||||
self.addWidget(self.table)
|
self.addWidget(self.table)
|
||||||
|
|
||||||
|
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
|
delete_action = QtGui.QAction("Delete", self.table)
|
||||||
|
delete_action.triggered.connect(self.delete_clicked)
|
||||||
|
self.table.addAction(delete_action)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def sub_connect(self, host, port):
|
def sub_connect(self, host, port):
|
||||||
self.subscriber = Subscriber("schedule", self.init_schedule_model)
|
self.subscriber = Subscriber("schedule", self.init_schedule_model)
|
||||||
@ -66,6 +73,17 @@ class ScheduleDock(dockarea.Dock):
|
|||||||
yield from self.subscriber.close()
|
yield from self.subscriber.close()
|
||||||
|
|
||||||
def init_schedule_model(self, init):
|
def init_schedule_model(self, init):
|
||||||
table_model = _ScheduleModel(self.table, init)
|
self.table_model = _ScheduleModel(self.table, init)
|
||||||
self.table.setModel(table_model)
|
self.table.setModel(self.table_model)
|
||||||
return table_model
|
return self.table_model
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def delete(self, rid):
|
||||||
|
yield from self.schedule_ctl.delete(rid)
|
||||||
|
|
||||||
|
def delete_clicked(self):
|
||||||
|
idx = self.table.selectedIndexes()
|
||||||
|
if idx:
|
||||||
|
row = idx[0].row()
|
||||||
|
rid = self.table_model.row_to_key[row]
|
||||||
|
asyncio.async(self.delete(rid))
|
||||||
|
Loading…
Reference in New Issue
Block a user