forked from M-Labs/artiq
interactive_args: add default message
This commit is contained in:
parent
af11dc6b74
commit
856e43fd61
|
@ -70,18 +70,27 @@ class _InteractiveArgsRequest(EntryTreeWidget):
|
||||||
self.cancelled.emit(self.rid)
|
self.cancelled.emit(self.rid)
|
||||||
|
|
||||||
|
|
||||||
class _InteractiveArgsView(QtWidgets.QTabWidget):
|
class _InteractiveArgsView(QtWidgets.QStackedWidget):
|
||||||
supplied = QtCore.pyqtSignal(int, dict)
|
supplied = QtCore.pyqtSignal(int, dict)
|
||||||
cancelled = QtCore.pyqtSignal(int)
|
cancelled = QtCore.pyqtSignal(int)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QtWidgets.QTabWidget.__init__(self)
|
QtWidgets.QStackedWidget.__init__(self)
|
||||||
|
self.tabs = QtWidgets.QTabWidget()
|
||||||
|
self.default_label = QtWidgets.QLabel("No pending interactive arguments requests.")
|
||||||
|
self.default_label.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
|
font = QtGui.QFont(self.default_label.font())
|
||||||
|
font.setItalic(True)
|
||||||
|
self.default_label.setFont(font)
|
||||||
|
self.addWidget(self.tabs)
|
||||||
|
self.addWidget(self.default_label)
|
||||||
self.model = Model({})
|
self.model = Model({})
|
||||||
|
|
||||||
def setModel(self, model):
|
def setModel(self, model):
|
||||||
for i in range(self.count()):
|
self.setCurrentIndex(1)
|
||||||
widget = self.widget(i)
|
for i in range(self.tabs.count()):
|
||||||
self.removeTab(i)
|
widget = self.tabs.widget(i)
|
||||||
|
self.tabs.removeTab(i)
|
||||||
widget.deleteLater()
|
widget.deleteLater()
|
||||||
self.model = model
|
self.model = model
|
||||||
self.model.rowsInserted.connect(self.rowsInserted)
|
self.model.rowsInserted.connect(self.rowsInserted)
|
||||||
|
@ -96,17 +105,20 @@ class _InteractiveArgsView(QtWidgets.QTabWidget):
|
||||||
inter_args_request = _InteractiveArgsRequest(rid, arglist_desc)
|
inter_args_request = _InteractiveArgsRequest(rid, arglist_desc)
|
||||||
inter_args_request.supplied.connect(self.supplied)
|
inter_args_request.supplied.connect(self.supplied)
|
||||||
inter_args_request.cancelled.connect(self.cancelled)
|
inter_args_request.cancelled.connect(self.cancelled)
|
||||||
self.insertTab(row, inter_args_request, title)
|
self.tabs.insertTab(row, inter_args_request, title)
|
||||||
|
|
||||||
def rowsInserted(self, parent, first, last):
|
def rowsInserted(self, parent, first, last):
|
||||||
assert first == last
|
assert first == last
|
||||||
|
self.setCurrentIndex(0)
|
||||||
self._insert_widget(first)
|
self._insert_widget(first)
|
||||||
|
|
||||||
def rowsRemoved(self, parent, first, last):
|
def rowsRemoved(self, parent, first, last):
|
||||||
assert first == last
|
assert first == last
|
||||||
widget = self.widget(first)
|
widget = self.tabs.widget(first)
|
||||||
self.removeTab(first)
|
self.tabs.removeTab(first)
|
||||||
widget.deleteLater()
|
widget.deleteLater()
|
||||||
|
if self.tabs.count() == 0:
|
||||||
|
self.setCurrentIndex(1)
|
||||||
|
|
||||||
|
|
||||||
class InteractiveArgsDock(QtWidgets.QDockWidget):
|
class InteractiveArgsDock(QtWidgets.QDockWidget):
|
||||||
|
|
Loading…
Reference in New Issue