Esempio n. 1
0
    def __init__(self, file = None):
        QtGui.QMainWindow.__init__(self)

        # This is always the same
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Since the UI is a QGraphicsView, I create a Scene
        # so it has something to show
        self.scene = QtGui.QGraphicsScene()
        self.ui.view.setScene(self.scene)

        # This makes the view OpenGL-accelerated. Usually makes
        # things much faster, but it *is* optional.

        self.ui.view.setViewport(QtOpenGL.QGLWidget())
        self.populate(file)
        runner.__init__(self, self.components)

        self.scene.setSceneRect(self.scene.itemsBoundingRect())
        self.setWindowState(QtCore.Qt.WindowMaximized)

        # Create a timer
        self.animator=QtCore.QTimer()

        # And when it triggers, it calls the animate method
        self.animator.timeout.connect(self.clock)

        # And I animate it once manually.
        self.animator.start(1000)
Esempio n. 2
0
class qRunner(runner, QtGui.QMainWindow):
    def __init__(self, file = None):
        QtGui.QMainWindow.__init__(self)

        # This is always the same
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Since the UI is a QGraphicsView, I create a Scene
        # so it has something to show
        self.scene = QtGui.QGraphicsScene()
        self.ui.view.setScene(self.scene)

        # This makes the view OpenGL-accelerated. Usually makes
        # things much faster, but it *is* optional.

        self.ui.view.setViewport(QtOpenGL.QGLWidget())
        self.populate(file)
        runner.__init__(self, self.components)

        self.scene.setSceneRect(self.scene.itemsBoundingRect())
        self.setWindowState(QtCore.Qt.WindowMaximized)

        # Create a timer
        self.animator=QtCore.QTimer()

        # And when it triggers, it calls the animate method
        self.animator.timeout.connect(self.clock)

        # And I animate it once manually.
        self.animator.start(1000)

    def clock(self):
        runner.clock(self)
        if len(self.unfinished_procs) == 0:
            print "Finished in %d cycles." % simulator.cycle
            QApplication.quit()
        for c in self.components:
            c.update_color()

    def populate(self, file):
        inst = qInstanciator(self.scene)
        inst.make(file)
        self.components = inst.get_components()