Python PyQt5.QtWidgets 模块,QGraphicsView() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用PyQt5.QtWidgets.QGraphicsView()

项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def wheelEvent(self, event: QtGui.QWheelEvent):
        if event.modifiers() & QtCore.Qt.ShiftModifier:
            delta = event.angleDelta()
            if delta.y() > 0:
                scale = self.zoom_in
            else:
                scale = 1 / self.zoom_in

            # Set Anchors
            self.setResizeAnchor(QtWidgets.QGraphicsView.NoAnchor)
            self.setTransformationAnchor(QtWidgets.QGraphicsView.NoAnchor)

            cur_pos = self.mapToScene(event.pos())
            self.scale(scale, scale)
            new_pos = self.mapToScene(event.pos())
            delta_zoomed = new_pos - cur_pos
            self.translate(delta_zoomed.x(), delta_zoomed.y())

            event.accept()
            return

        return super(VQVivFuncGraphCanvas, self).wheelEvent(event)
项目:git-annex-metadata-gui    作者:alpernebbi    | 项目源码 | 文件源码
def addWidget(self, widget):
        super().addWidget(widget)
        if isinstance(widget, QtWidgets.QPlainTextEdit):
            self.text_preview = widget
        if isinstance(widget, QtWidgets.QGraphicsView):
            self.graphics_preview = widget
项目:plexdesktop    作者:coryo    | 项目源码 | 文件源码
def keyReleaseEvent(self, event):
        if event.key() == QtCore.Qt.Key_Space and not event.isAutoRepeat():
            self.setDragMode(QtWidgets.QGraphicsView.NoDrag)
            self.setInteractive(False)
        elif event.key() == QtCore.Qt.Key_Control:
            self.setInteractive(False)
        else:
            super().keyReleaseEvent(event)
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, vw, syms, parent, *args, **kwargs):
        self.vw = vw
        self.syms = syms

        QtWidgets.QGraphicsView.__init__(self, parent=parent)
        e_qt_memory.EnviNavMixin.__init__(self)

        self.scene = DropGraphicsScene(parent=self)
        self.setScene(self.scene)

        self.scene.setStickyFocus(True)
        self.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)
        self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(self.bg_color)))
        self.setViewportUpdateMode(QtWidgets.QGraphicsView.BoundingRectViewportUpdate)
        self.setRenderHints(self.renderHints() | QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform)

        self._orig_transform = self.transform()
        self._edge_pen = QtGui.QPen(QtGui.QBrush(QtGui.QColor(self.true_edge_color)), self.edge_width,
                                    QtCore.Qt.SolidLine, QtCore.Qt.RoundCap)

        ##################################################################
        # Function graph related stuff

        # holds the memory canvas instances for each basic block
        self._block_views = dict()
        self.func_va = None
        self.func_graph = None
        # the layout used for this graph
        self.graph_layout = None

        self._rend = viv_rend.WorkspaceRenderer(vw)
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, vg, nodes, parent=None):
        QtWidgets.QGraphicsView.__init__(self, parent=parent)
        scene = QtWidgets.QGraphicsScene(parent=self)

        self.setScene(scene)
        self._v_nodecol = NodeColumn(vg, nodes, scene)
        self._v_vg = vg
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, graph, parent=None):
        QtWidgets.QGraphicsView.__init__(self, parent=parent)
        vg_render.GraphRenderer.__init__(self, graph)

        scene = QtWidgets.QGraphicsScene(parent=self)
        self.setScene(scene)
项目:mindfulness-at-the-computer    作者:SunyataZero    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()
        self.show()
        self.setMinimumHeight(300)
        self.setMinimumWidth(270)

        self.ib_qtimer = None
        self.ob_qtimer = None
        self.updating_gui_bool = False
        # self.breathing_rest_counter_int = 0
        # self.breath_counter_int = 0
        self.new_cycle_bool = True

        self.in_breath_graphics_qgri_list = []
        self.out_breath_graphics_qgri_list = []

        vbox_l2 = QtWidgets.QVBoxLayout()
        self.setLayout(vbox_l2)

        self.breathing_graphicsview = QtWidgets.QGraphicsView()  # QGraphicsScene
        vbox_l2.addWidget(self.breathing_graphicsview)
        self.breathing_graphicsscene = QtWidgets.QGraphicsScene()
        self.breathing_graphicsview.setScene(self.breathing_graphicsscene)
        # self.breathing_graphicsview.centerOn(QtCore.Qt.AlignRight)
        # alignment can be set with "setAlignment"
        self.breathing_graphicsview.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)
项目:PointlessMaker    作者:aboood40091    | 项目源码 | 文件源码
def __init__(self, scene, parent):
        super().__init__(scene, parent)

        self.setAlignment(Qt.AlignLeft | Qt.AlignTop)
        self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
        self.setMouseTracking(True)
        self.YScrollBar = QtWidgets.QScrollBar(Qt.Vertical, parent)
        self.XScrollBar = QtWidgets.QScrollBar(Qt.Horizontal, parent)
        self.setVerticalScrollBar(self.YScrollBar)
        self.setHorizontalScrollBar(self.XScrollBar)

        self.currentobj = None

        self.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform)
项目:ezdmb    作者:angryrancor    | 项目源码 | 文件源码
def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(720, 480)
        MainWindow.setIconSize(QtCore.QSize(18, 18))
        MainWindow.setDocumentMode(False)
        self.centralWidget = QtWidgets.QWidget(MainWindow)
        self.centralWidget.setObjectName("centralWidget")
        self.btnNewImage = QtWidgets.QPushButton(self.centralWidget)
        self.btnNewImage.setGeometry(QtCore.QRect(469, 200, 171, 61))
        font = QtGui.QFont()
        font.setPointSize(16)
        self.btnNewImage.setFont(font)
        self.btnNewImage.setObjectName("btnNewImage")
        self.graphicsView = QtWidgets.QGraphicsView(self.centralWidget)
        self.graphicsView.setGeometry(QtCore.QRect(40, 120, 360, 240))
        self.graphicsView.setObjectName("graphicsView")
        self.label = QtWidgets.QLabel(self.centralWidget)
        self.label.setGeometry(QtCore.QRect(40, 20, 631, 71))
        font = QtGui.QFont()
        font.setPointSize(32)
        font.setUnderline(True)
        self.label.setFont(font)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setWordWrap(False)
        self.label.setObjectName("label")
        MainWindow.setCentralWidget(self.centralWidget)
        self.menuBar = QtWidgets.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 720, 17))
        self.menuBar.setObjectName("menuBar")
        MainWindow.setMenuBar(self.menuBar)
        self.mainToolBar = QtWidgets.QToolBar(MainWindow)
        self.mainToolBar.setObjectName("mainToolBar")
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
        self.statusBar = QtWidgets.QStatusBar(MainWindow)
        self.statusBar.setObjectName("statusBar")
        MainWindow.setStatusBar(self.statusBar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
项目:songscreen    作者:maccesch    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(SongTextWidget, self).__init__(*args, **kwargs)

        self.setWindowTitle(self.tr("Lyrics"))

        self.w = 1920
        self.h = 1080

        self._progress = 0.0
        # self._animated_progress = 0.0

        self.title = ""

        self._linecount = 0
        self._extra_lines_after = []
        self._first_lyrics_line_y = 0

        self._covered = True

        self.setMinimumHeight(9 * 50)
        self.setMinimumWidth(16 * 50)

        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)

        self.setScene(QGraphicsScene(self))
        self.setRenderHints(QPainter.HighQualityAntialiasing | QPainter.SmoothPixmapTransform)
        self.setInteractive(False)
        self.scene().setBackgroundBrush(Qt.black)
        self.setStyleSheet( "QGraphicsView { border-style: none; }" )

        self._line_height = 10
        self._document_height = 10

        self._animation = None

        self._font_size = 40
        self._line_increment = 2
项目:echolocation    作者:hgross    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)

        width, height = 800, 800
        self.setGeometry(width, height, width, height)

        # configs, can be changed at runtime
        self.circle_line_color = Qt.gray
        self.crosshair_line_color = Qt.gray
        self.text_label_color = Qt.darkGreen
        self.measured_distances_color = Qt.green
        self.circle_count = 10
        self.dot_width = 10
        self.line_width = 1
        self.distance_measurement_angle = 15
        self.measurement_angle = 10  # degrees that one sensor covers
        self.fade_out_time = 4  # older measurements will fade out over this time
        self.add_text_labels = False

        # data
        self.measurements = []
        self.added_time = dict()  # measurement -> timestamp

        # drawing timer
        self.timer = QTimer()
        self.timer.setInterval(80)
        self.timer.timeout.connect(self.draw_radar)
        self.timer.start()

        # internal canvas setup
        self.layout = QHBoxLayout()
        self.setLayout(self.layout)
        self.scene = QGraphicsScene()
        self.scene.setSceneRect(0, 0, width, height)
        self.canvas = QGraphicsView()
        self.canvas.setRenderHint(QPainter.Antialiasing)
        self.canvas.setFixedSize(width, height)
        self.canvas.setAlignment(Qt.AlignLeft)
        self.canvas.setScene(self.scene)
        self.canvas.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.canvas.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.layout.addWidget(self.canvas)

        # initial rendering
        self.draw_radar()
项目:Laborejo    作者:hilbrichtsoftware    | 项目源码 | 文件源码
def __init__(self, mainWindow):
        super().__init__()
        self.mainWindow = mainWindow


        viewport = QtOpenGL.QGLWidget(QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers))
        viewport.format().setSwapInterval(0) #disable VSync.
        viewport.setAutoFillBackground(False)

        viewport = QtWidgets.QOpenGLWidget()
        viewportFormat = QtGui.QSurfaceFormat()
        viewportFormat.setSwapInterval(0) #disable VSync
        viewportFormat.setSamples(2**8)
        viewportFormat.setDefaultFormat(viewportFormat)
        viewport.setFormat(viewportFormat)
        self.setViewport(viewport)

        self.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        #self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
        self.setDragMode(QtWidgets.QGraphicsView.NoDrag)

        self.scoreScene = GuiScore(self)
        self.setScene(self.scoreScene)

        api.getCallbacksDatabase().setCursor.append(self.centerOnCursor) #returns a dict
        api.getCallbacksDatabase().updateBlockTrack.append(self.updateMode)

        self.xFactor = 1 #keep track of the x stretch factor.

        style = """
        QScrollBar:horizontal {
            border: 1px solid black;
        }

        QScrollBar::handle:horizontal {
            background: #00b2b2;
        }

        QScrollBar:vertical {
            border: 1px solid black;
        }

        QScrollBar::handle:vertical {
            background: #00b2b2;
        }
        """
        self.setStyleSheet(style)

        self._zoom() #no parameters, uses config values