Esempio n. 1
0
    def __init__(self, scene, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        # self.windowTitleChanged.connect(self.onWindowTitleChange)
        self.setWindowTitle("timeline0")

        toolbar = QToolBar("och")
        toolbar.setIconSize(QSize(20, 20))
        self.addToolBar(toolbar)

        button_action = QAction(QIcon("balance.png"), "ochtuse", self)
        button_action.setStatusTip("och, just do something")
        button_action.triggered.connect(self.onMyToolBarButtonClick)
        button_action.setCheckable(True)
        # button_action.setShortcut(QKeySequence("Ctrl+p"))
        # button_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_P))
        button_action.setShortcut(QKeySequence.Print)
        toolbar.addAction(button_action)
        toolbar.addWidget(QLabel("OCH"))
        toolbar.addWidget(QCheckBox())

        self.setStatusBar(QStatusBar(self))

        menu = self.menuBar()

        file_menu = menu.addMenu("&File")
        file_menu.addAction(button_action)
        file_menu.addSeparator()
        file_menu.addMenu("Do not push")
        #        file_menu.addAction()

        self._scene = scene
        gfx = self._gfx = QGraphicsView(self)
        # label = QLabel("och!")
        # label.setAlignment(Qt.AlignCenter)

        # ref https://doc.qt.io/archives/qq/qq26-openglcanvas.html
        self.setCentralWidget(gfx)
        fmt = QGLFormat(QGL.SampleBuffers)
        wdgt = QGLWidget(fmt)
        assert (wdgt.isValid())
        gfx.setViewport(wdgt)
        gfx.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
        gfx.setScene(scene)

        # populate fills the scene with interesting stuff.
        self.populate()

        # Make it bigger
        self.setWindowState(Qt.WindowMaximized)

        # Well... it's going to have an animation, ok?

        # So, I set a timer to 1 second
        self.animator = QTimer()

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

        # And I animate it once manually.
        self.animate()
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     super(QFramesInTracksView, self).__init__(*args, **kwargs)
     fmt = QGLFormat(QGL.SampleBuffers)
     wdgt = QGLWidget(fmt)
     assert (wdgt.isValid())
     self.setViewport(wdgt)
     self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
     self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
     self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
     self.setRenderHints(QPainter.Antialiasing)