Пример #1
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setModal(True)
        self.setWindowTitle("Running jobs")
        self.setMinimumWidth(250)
        #self.setMinimumHeight(250)
        
        self.ctrl = SimulationsDialogController(self) 

        self.simulationProgress = QtGui.QProgressBar()
        self.simulationProgress.setValue(0)
        self.connect(self.simulationProgress, QtCore.SIGNAL('setValue(int)'), self.updateProgress)

        self.cogwheel = Cogwheel(size=20)

        memberLayout = QtGui.QVBoxLayout()

        progressLayout = QtGui.QHBoxLayout()
        progressLayout.addWidget(self.simulationProgress)
        progressLayout.addWidget(self.cogwheel)
        memberLayout.addLayout(progressLayout)


        simulationLayout = QtGui.QHBoxLayout()
        self.simulationList = SimulationList()
        self.simulationList.contextMenuEvent = self._contextMenu
        self.connect(self.simulationList, QtCore.SIGNAL('itemSelectionChanged()'), self.ctrl.selectSimulation)
        simulationLayout.addWidget(self.simulationList)
        self.simulationPanel = SimulationPanel()
        simulationLayout.addWidget(self.simulationPanel)
        memberLayout.addLayout(simulationLayout)

        legendLayout = QtGui.QHBoxLayout()
        legendLayout.addLayout(Legend("Not active", SimulationItemDelegate.notactive))
        legendLayout.addLayout(Legend("Waiting", SimulationItemDelegate.waiting))
        legendLayout.addLayout(Legend("Pending", SimulationItemDelegate.pending))
        legendLayout.addLayout(Legend("Running", SimulationItemDelegate.running))
        legendLayout.addLayout(Legend("User killed", SimulationItemDelegate.userkilled))
        legendLayout.addLayout(Legend("Failed", SimulationItemDelegate.failed))
        legendLayout.addLayout(Legend("Finished", SimulationItemDelegate.finished))
        memberLayout.addLayout(legendLayout)


        self.doneButton = QtGui.QPushButton("Done", self)
        self.connect(self.doneButton, QtCore.SIGNAL('clicked()'), self.accept)

        buttonLayout = QtGui.QHBoxLayout()

        self.estimateLabel = QtGui.QLabel()
        buttonLayout.addWidget(self.estimateLabel)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.doneButton)

        memberLayout.addSpacing(10)
        memberLayout.addLayout(buttonLayout)

        self.setLayout(memberLayout)
Пример #2
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setModal(True)
        self.setWindowTitle("Running jobs")
        self.setMinimumWidth(250)
        #self.setMinimumHeight(250)

        self.ctrl = SimulationsDialogController(self)

        self.simulationProgress = QtGui.QProgressBar()
        self.simulationProgress.setValue(0)
        self.connect(self.simulationProgress, QtCore.SIGNAL('setValue(int)'),
                     self.updateProgress)

        self.cogwheel = Cogwheel(size=20)

        memberLayout = QtGui.QVBoxLayout()

        progressLayout = QtGui.QHBoxLayout()
        progressLayout.addWidget(self.simulationProgress)
        progressLayout.addWidget(self.cogwheel)
        memberLayout.addLayout(progressLayout)

        simulationLayout = QtGui.QHBoxLayout()
        self.simulationList = SimulationList()
        self.simulationList.contextMenuEvent = self._contextMenu
        self.connect(self.simulationList,
                     QtCore.SIGNAL('itemSelectionChanged()'),
                     self.ctrl.selectSimulation)
        simulationLayout.addWidget(self.simulationList)
        self.simulationPanel = SimulationPanel()
        simulationLayout.addWidget(self.simulationPanel)
        memberLayout.addLayout(simulationLayout)

        legendLayout = QtGui.QHBoxLayout()
        legendLayout.addLayout(
            Legend("Not active", SimulationItemDelegate.notactive))
        legendLayout.addLayout(
            Legend("Waiting", SimulationItemDelegate.waiting))
        legendLayout.addLayout(
            Legend("Pending", SimulationItemDelegate.pending))
        legendLayout.addLayout(
            Legend("Running", SimulationItemDelegate.running))
        legendLayout.addLayout(
            Legend("User killed", SimulationItemDelegate.userkilled))
        legendLayout.addLayout(Legend("Failed", SimulationItemDelegate.failed))
        legendLayout.addLayout(
            Legend("Finished", SimulationItemDelegate.finished))
        memberLayout.addLayout(legendLayout)

        self.doneButton = QtGui.QPushButton("Done", self)
        self.connect(self.doneButton, QtCore.SIGNAL('clicked()'), self.accept)

        buttonLayout = QtGui.QHBoxLayout()

        self.estimateLabel = QtGui.QLabel()
        buttonLayout.addWidget(self.estimateLabel)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.doneButton)

        memberLayout.addSpacing(10)
        memberLayout.addLayout(buttonLayout)

        self.setLayout(memberLayout)
Пример #3
0
class SimulationsDialog(QtGui.QDialog):
    """A dialog that shows the progress of a simulation"""
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setModal(True)
        self.setWindowTitle("Running jobs")
        self.setMinimumWidth(250)
        #self.setMinimumHeight(250)
        
        self.ctrl = SimulationsDialogController(self) 

        self.simulationProgress = QtGui.QProgressBar()
        self.simulationProgress.setValue(0)
        self.connect(self.simulationProgress, QtCore.SIGNAL('setValue(int)'), self.updateProgress)

        self.cogwheel = Cogwheel(size=20)

        memberLayout = QtGui.QVBoxLayout()

        progressLayout = QtGui.QHBoxLayout()
        progressLayout.addWidget(self.simulationProgress)
        progressLayout.addWidget(self.cogwheel)
        memberLayout.addLayout(progressLayout)


        simulationLayout = QtGui.QHBoxLayout()
        self.simulationList = SimulationList()
        self.simulationList.contextMenuEvent = self._contextMenu
        self.connect(self.simulationList, QtCore.SIGNAL('itemSelectionChanged()'), self.ctrl.selectSimulation)
        simulationLayout.addWidget(self.simulationList)
        self.simulationPanel = SimulationPanel()
        simulationLayout.addWidget(self.simulationPanel)
        memberLayout.addLayout(simulationLayout)

        legendLayout = QtGui.QHBoxLayout()
        legendLayout.addLayout(Legend("Not active", SimulationItemDelegate.notactive))
        legendLayout.addLayout(Legend("Waiting", SimulationItemDelegate.waiting))
        legendLayout.addLayout(Legend("Pending", SimulationItemDelegate.pending))
        legendLayout.addLayout(Legend("Running", SimulationItemDelegate.running))
        legendLayout.addLayout(Legend("User killed", SimulationItemDelegate.userkilled))
        legendLayout.addLayout(Legend("Failed", SimulationItemDelegate.failed))
        legendLayout.addLayout(Legend("Finished", SimulationItemDelegate.finished))
        memberLayout.addLayout(legendLayout)


        self.doneButton = QtGui.QPushButton("Done", self)
        self.connect(self.doneButton, QtCore.SIGNAL('clicked()'), self.accept)

        buttonLayout = QtGui.QHBoxLayout()

        self.estimateLabel = QtGui.QLabel()
        buttonLayout.addWidget(self.estimateLabel)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.doneButton)

        memberLayout.addSpacing(10)
        memberLayout.addLayout(buttonLayout)

        self.setLayout(memberLayout)


    def _createAction(self, name, func, parent=None):
        """Create an action for the right click menu"""
        action = QtGui.QAction(name, parent)
        action.connect(action, QtCore.SIGNAL("triggered()"), func)
        return action

    def _contextMenu(self, event):
        """Create a right click menu for the simulation view."""
        menu = QtGui.QMenu(self.simulationList)
        selectAll = self._createAction("Select all", self.simulationList.selectAll)
        unselectAll = self._createAction("Unselect all", self.simulationList.clearSelection)
        selectRunning = self._createAction("Select all running", lambda : self.ctrl.select(ert_job_status_type.RUNNING))
        selectFailed = self._createAction("Select all failed", lambda : self.ctrl.select(ert_job_status_type.ALL_FAIL))
        selectUserKilled = self._createAction("Select all user killed", lambda : self.ctrl.select(ert_job_status_type.USER_KILLED))
        selectWaiting = self._createAction("Select all waiting", lambda : self.ctrl.select(ert_job_status_type.WAITING, ert_job_status_type.PENDING))

        menu.addAction(selectAll)
        menu.addAction(unselectAll)
        menu.addAction(selectWaiting)
        menu.addAction(selectRunning)
        menu.addAction(selectFailed)
        menu.addAction(selectUserKilled)
        menu.exec_(event.globalPos())
        

    def closeEvent(self, event):
        """Ignore clicking of the x in the top right corner"""
        event.ignore()

    def keyPressEvent(self, event):
        """Ignore ESC keystrokes"""
        if not event.key() == QtCore.Qt.Key_Escape:
            QtGui.QDialog.keyPressEvent(self, event)

    def updateProgress(self, value):
        """Update the progress bar"""
        self.simulationProgress.setValue(value)

    def setRunningState(self, state):
        """Set wether the cogwheel should spin and the Done button is enabled"""
        self.cogwheel.setRunning(state)
        self.doneButton.setEnabled(not state)

    def start(self, **kwargs):
        """Show the dialog and start the simulation"""
        self.open()
        self.ctrl.start(**kwargs)
        self.exec_()
Пример #4
0
class SimulationsDialog(QtGui.QDialog):
    """A dialog that shows the progress of a simulation"""
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setModal(True)
        self.setWindowTitle("Running jobs")
        self.setMinimumWidth(250)
        #self.setMinimumHeight(250)

        self.ctrl = SimulationsDialogController(self)

        self.simulationProgress = QtGui.QProgressBar()
        self.simulationProgress.setValue(0)
        self.connect(self.simulationProgress, QtCore.SIGNAL('setValue(int)'),
                     self.updateProgress)

        self.cogwheel = Cogwheel(size=20)

        memberLayout = QtGui.QVBoxLayout()

        progressLayout = QtGui.QHBoxLayout()
        progressLayout.addWidget(self.simulationProgress)
        progressLayout.addWidget(self.cogwheel)
        memberLayout.addLayout(progressLayout)

        simulationLayout = QtGui.QHBoxLayout()
        self.simulationList = SimulationList()
        self.simulationList.contextMenuEvent = self._contextMenu
        self.connect(self.simulationList,
                     QtCore.SIGNAL('itemSelectionChanged()'),
                     self.ctrl.selectSimulation)
        simulationLayout.addWidget(self.simulationList)
        self.simulationPanel = SimulationPanel()
        simulationLayout.addWidget(self.simulationPanel)
        memberLayout.addLayout(simulationLayout)

        legendLayout = QtGui.QHBoxLayout()
        legendLayout.addLayout(
            Legend("Not active", SimulationItemDelegate.notactive))
        legendLayout.addLayout(
            Legend("Waiting", SimulationItemDelegate.waiting))
        legendLayout.addLayout(
            Legend("Pending", SimulationItemDelegate.pending))
        legendLayout.addLayout(
            Legend("Running", SimulationItemDelegate.running))
        legendLayout.addLayout(
            Legend("User killed", SimulationItemDelegate.userkilled))
        legendLayout.addLayout(Legend("Failed", SimulationItemDelegate.failed))
        legendLayout.addLayout(
            Legend("Finished", SimulationItemDelegate.finished))
        memberLayout.addLayout(legendLayout)

        self.doneButton = QtGui.QPushButton("Done", self)
        self.connect(self.doneButton, QtCore.SIGNAL('clicked()'), self.accept)

        buttonLayout = QtGui.QHBoxLayout()

        self.estimateLabel = QtGui.QLabel()
        buttonLayout.addWidget(self.estimateLabel)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.doneButton)

        memberLayout.addSpacing(10)
        memberLayout.addLayout(buttonLayout)

        self.setLayout(memberLayout)

    def _createAction(self, name, func, parent=None):
        """Create an action for the right click menu"""
        action = QtGui.QAction(name, parent)
        action.connect(action, QtCore.SIGNAL("triggered()"), func)
        return action

    def _contextMenu(self, event):
        """Create a right click menu for the simulation view."""
        menu = QtGui.QMenu(self.simulationList)
        selectAll = self._createAction("Select all",
                                       self.simulationList.selectAll)
        unselectAll = self._createAction("Unselect all",
                                         self.simulationList.clearSelection)
        selectRunning = self._createAction(
            "Select all running",
            lambda: self.ctrl.select(ert_job_status_type.RUNNING))
        selectFailed = self._createAction(
            "Select all failed",
            lambda: self.ctrl.select(ert_job_status_type.ALL_FAIL))
        selectUserKilled = self._createAction(
            "Select all user killed",
            lambda: self.ctrl.select(ert_job_status_type.USER_KILLED))
        selectWaiting = self._createAction(
            "Select all waiting", lambda: self.ctrl.select(
                ert_job_status_type.WAITING, ert_job_status_type.PENDING))

        menu.addAction(selectAll)
        menu.addAction(unselectAll)
        menu.addAction(selectWaiting)
        menu.addAction(selectRunning)
        menu.addAction(selectFailed)
        menu.addAction(selectUserKilled)
        menu.exec_(event.globalPos())

    def closeEvent(self, event):
        """Ignore clicking of the x in the top right corner"""
        event.ignore()

    def keyPressEvent(self, event):
        """Ignore ESC keystrokes"""
        if not event.key() == QtCore.Qt.Key_Escape:
            QtGui.QDialog.keyPressEvent(self, event)

    def updateProgress(self, value):
        """Update the progress bar"""
        self.simulationProgress.setValue(value)

    def setRunningState(self, state):
        """Set wether the cogwheel should spin and the Done button is enabled"""
        self.cogwheel.setRunning(state)
        self.doneButton.setEnabled(not state)

    def start(self, **kwargs):
        """Show the dialog and start the simulation"""
        self.open()
        self.ctrl.start(**kwargs)
        self.exec_()