本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsView方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QGraphicsView方法的具体用法?Python QtWidgets.QGraphicsView怎么用?Python QtWidgets.QGraphicsView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QGraphicsView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self):
super().__init__()
self.show()
self.setMinimumHeight(300)
self.ib_qtimer = None
self.ob_qtimer = None
self.updating_gui_bool = False
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)
# vbox_l2.addWidget(QtWidgets.QLabel("Breathing History"))
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)
开发者ID:mindfulness-at-the-computer,项目名称:mindfulness-at-the-computer,代码行数:26,代码来源:breathing_history_wt.py
示例2: mouseMoveEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def mouseMoveEvent(self, event):
# Compare mouse positions
# This allows to filter out scrolling
# from a normal mouseEvent
QtWidgets.QGraphicsView.mouseMoveEvent(self, event)
if not self.mousePosition:
self.mousePosition = event.pos()
return
current_position = event.pos()
if current_position == self.mousePosition or self.parent.sideDock.isVisible():
return
else:
self.mousePosition = event.pos()
self.parent.navBar.show()
if QtWidgets.QApplication.mouseButtons() == QtCore.Qt.NoButton:
self.viewport().setCursor(QtCore.Qt.OpenHandCursor)
else:
self.viewport().setCursor(QtCore.Qt.ClosedHandCursor)
self.parent.mouseHideTimer.start(2000)
示例3: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self):
super().__init__()
self.setObjectName('map-view')
self.scene = QtWidgets.QGraphicsScene()
self.setScene(self.scene)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setTransformationAnchor(QtWidgets.QGraphicsView.NoAnchor)
self.setResizeAnchor(QtWidgets.QGraphicsView.NoAnchor)
self.setMouseTracking(True)
self.current_column = -1
self.current_row = -1
# TODO hardcore tile size somewhere else (and a bit less hard)
self.TILE_SIZE = 80
示例4: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self, plugin):
"""
Initialize the Overview.
:type plugin: Overview
"""
super().__init__(plugin.parent())
self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
self.setMinimumSize(QtCore.QSize(216, 216))
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setOptimizationFlags(QtWidgets.QGraphicsView.DontAdjustForAntialiasing)
self.setOptimizationFlags(QtWidgets.QGraphicsView.DontSavePainterState)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setViewportUpdateMode(QtWidgets.QGraphicsView.NoViewportUpdate)
self._mousePressed = False
self._view = None
#############################################
# PROPERTIES
#################################
示例5: ok
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def ok(self):
self.gridLayoutWidget = QtWidgets.QWidget()
self.gridLayoutWidget.setGeometry(QtCore.QRect(180, 10, 1100, 500)) # 定义gridLayout控件的大小和位置,4个数字分别为左边坐标,上边坐标,长,宽
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout_2 = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout_2.setContentsMargins(0, 0, 0, 0) # 在gridLayoutWidget 上创建一个网格Layout,注意以gridLayoutWidget为参
self.gridLayout_2.setObjectName("gridLayout_2")
# ===通过graphicview来显示图形
self.graphicview = QtWidgets.QGraphicsView(self.gridLayoutWidget) # 第一步,创建一个QGraphicsView,注意同样以gridLayoutWidget为参
self.graphicview.setObjectName("graphicview")
self.gridLayout_2.addWidget(self.graphicview, 0, 0) #第二步,将该QGraphicsView放入Layout中
dr = Figure_Canvas() #实例化一个FigureCanvas
dr.test() # 画图
graphicscene = QtWidgets.QGraphicsScene() # 第三步,创建一个QGraphicsScene,因为加载的图形(FigureCanvas)不能直接放到graphicview控件中,必须先放到graphicScene,然后再把graphicscene放到graphicview中
graphicscene.addWidget(dr) # 第四步,把图形放到QGraphicsScene中,注意:图形是作为一个QWidget放到QGraphicsScene中的
self.graphicview.setScene(graphicscene) # 第五步,把QGraphicsScene放入QGraphicsView
self.graphicview.show() # 最后,调用show方法呈现图形!Voila!!
示例6: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self, *args):
super(SymbolView, self).__init__(*args)
from UIManager import UIManager
self.setScene(UIManager.instance().getSymbolScene())
self.setViewportUpdateMode(QtWidgets.QGraphicsView.FullViewportUpdate)
self.setCacheMode(QtWidgets.QGraphicsView.CacheNone)
#self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse)
self.setMouseTracking(True)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setAcceptDrops(True)
self.setViewport(QtOpenGL.QGLWidget())
self.centerPnt = QtCore.QPointF()
self.scale(0.6,0.6)
self.mousePressPnt = None
self.mouseCurPnt = None
self.isFrameSelectMode = False
示例7: blurPixmap
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def blurPixmap(pixmap, radius):
effect = QGraphicsBlurEffect()
effect.setBlurRadius(radius)
buffer = QPixmap(pixmap)
item = QGraphicsPixmapItem(buffer)
item.setGraphicsEffect(effect)
output = QPixmap(pixmap.width(), pixmap.height())
painter = QtGui.QPainter(output)
scene = QtWidgets.QGraphicsScene()
view = QtWidgets.QGraphicsView(scene)
scene.addItem(item)
scene.render(painter)
return output
示例8: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self, *args, **kwargs):
"""
Set the transformation anchor to below the current mouse position.
"""
super().__init__(*args, **kwargs)
self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse)
示例9: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self, conf, defeat):
self.config = conf
super().__init__()
self.setWindowTitle(conf.get_text('victory'))
self.setFixedSize(QSize(640, 480))
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.WindowTitleHint | Qt.FramelessWindowHint)
button = QPushButton(conf.get_text('close'), self)
button.setCheckable(True)
button.setFixedSize(QSize(640, 30))
button.move(0, 450)
# noinspection PyUnresolvedReferences
button.clicked.connect(self.close)
result_output = QTextEdit(self)
result_output.setReadOnly(True)
result_output.setFixedSize(QSize(640, 200))
result_output.move(0, 250)
result_output.setLineWrapMode(QTextEdit.NoWrap)
result_output.insertHtml(self.generate_result_text())
gview = QGraphicsView(self)
scene = QGraphicsScene()
if defeat:
img = conf.theme_selected.get_defeat_pixmap()
text = conf.get_text('defeat')
else:
img = conf.theme_selected.get_victory_pixmap()
text = conf.get_text('victory')
scene.addPixmap(img.scaled(QSize(640, 220)))
gview.move(0, 30)
gview.setScene(scene)
label_title = QLabel(self)
label_title.setText(text)
label_title.setFixedSize(QSize(640, 30))
label_title.setAlignment(Qt.AlignCenter)
label_title.setFont(self.get_font_title())
示例10: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self, PFD=True, parent=None):
super(GraphicsView, self).__init__(parent)
self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
self.setRenderHint(QtGui.QPainter.Antialiasing)
self.setRenderHint(QtGui.QPainter.TextAntialiasing)
self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor("#aaaaaa"), QtCore.Qt.Dense7Pattern))
self.setMouseTracking(True)
# self.setAcceptDrops(True)
self.PFD = PFD
# def wheelEvent(self, event):
# print event.delta()
#
# factor = 1.41 ** (-event.delta() / 240.0)
# self.zoom(factor)
示例11: mouseMoveEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def mouseMoveEvent(self, event):
QtWidgets.QGraphicsView.mouseMoveEvent(self, event)
self.mouseMove.emit(event.globalPos())
示例12: mousePressEvent
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def mousePressEvent(self, event):
QtWidgets.QGraphicsView.mousePressEvent(self, event)
if not self.PFD:
self.scene().views()[0].centerOn(self.mapToScene(event.pos()))
示例13: scaleView
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def scaleView(self, zoom):
"""
Scale the view according to the given zoom.
:type zoom: float
"""
self.setTransformationAnchor(QtWidgets.QGraphicsView.NoAnchor)
self.setResizeAnchor(QtWidgets.QGraphicsView.NoAnchor)
self.resetTransform()
self.translate(self.transform().dx(), self.transform().dy())
self.scale(zoom, zoom)
self.sgnScaled.emit(zoom)
self.zoom = zoom
示例14: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self, parent=None):
super(Activeview, self).__init__(parent)
# self.setStyleSheet("border: 0px")
self.selfhandle = False
self.left = 1
# self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse)
# self.setResizeAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse)
# self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorViewCenter)
# self.setResizeAnchor(QtWidgets.QGraphicsView.AnchorViewCenter)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag) #
self.setMinimumSize(500, 500)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
self.setBackgroundBrush(brush)
#self.setAutoFillBackground(True)
self.zoomdata = 1
self.movelist = []
self.movelist.append(0)
self.movelist.append(0)
# def updateCanvas(self, data):
# self.__dyCanvas = data
#
# def getCanvas(self):
# return self.__dyCanvas
示例15: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsView [as 别名]
def __init__(self):
super().__init__()
self.mainscene = Scene(self)
self.view = QtWidgets.QGraphicsView(self.mainscene)
self.view.setRenderHint(QtGui.QPainter.Antialiasing)
self.setCentralWidget(self.view)
self.statusBar().showMessage(
"Ready. Sequences loaded from " + BaseSequencesFile + "."
)