本文整理匯總了Python中PyQt5.QtCore.QRectF方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QRectF方法的具體用法?Python QtCore.QRectF怎麽用?Python QtCore.QRectF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QRectF方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: drawSizeInfo
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def drawSizeInfo(self):
sizeInfoAreaWidth = 200
sizeInfoAreaHeight = 30
spacing = 5
rect = self.selected_area.normalized()
sizeInfoArea = QRect(rect.left(), rect.top() - spacing - sizeInfoAreaHeight,
sizeInfoAreaWidth, sizeInfoAreaHeight)
if sizeInfoArea.top() < 0:
sizeInfoArea.moveTopLeft(rect.topLeft() + QPoint(spacing, spacing))
if sizeInfoArea.right() >= self.screenPixel.width():
sizeInfoArea.moveTopLeft(rect.topLeft() - QPoint(spacing, spacing) - QPoint(sizeInfoAreaWidth, 0))
if sizeInfoArea.left() < spacing:
sizeInfoArea.moveLeft(spacing)
if sizeInfoArea.top() < spacing:
sizeInfoArea.moveTop(spacing)
self.items_to_remove.append(self.graphics_scene.addRect(QRectF(sizeInfoArea), Qt.white, QBrush(Qt.black)))
sizeInfo = self.graphics_scene.addSimpleText(
' {0} x {1}'.format(rect.width() * self.scale, rect.height() * self.scale))
sizeInfo.setPos(sizeInfoArea.topLeft() + QPoint(0, 2))
sizeInfo.setPen(QPen(QColor(255, 255, 255), 2))
self.items_to_remove.append(sizeInfo)
示例2: __init__
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def __init__(self, parent=None):
super(DesktopLyric, self).__init__()
self.lyric = QString('Lyric Show.')
self.intervel = 0
self.maskRect = QRectF(0, 0, 0, 0)
self.maskWidth = 0
self.widthBlock = 0
self.t = QTimer()
self.screen = QApplication.desktop().availableGeometry()
self.setObjectName(_fromUtf8("Dialog"))
self.setWindowFlags(Qt.CustomizeWindowHint | Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint | Qt.Tool)
self.setMinimumHeight(65)
self.setAttribute(Qt.WA_TranslucentBackground)
self.handle = lyric_handle(self)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.font = QFont(_fromUtf8('微軟雅黑, verdana'), 50)
self.font.setPixelSize(50)
# QMetaObject.connectSlotsByName(self)
self.handle.lyricmoved.connect(self.newPos)
self.t.timeout.connect(self.changeMask)
示例3: TypeChange
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def TypeChange(self):
"""
Handles the entrance's type changing
"""
# Determine the size and position of the entrance
x, y, w, h = 0, 0, 1, 1
if self.enttype in (3, 4):
# Vertical pipe
w = 2
elif self.enttype in (5, 6):
# Horizontal pipe
h = 2
# Now make the rects
self.RoundedRect = QtCore.QRectF(x * globals.TileWidth + 1, y * globals.TileWidth + 1, w * globals.TileWidth - 2, h * globals.TileWidth - 2)
self.BoundingRect = QtCore.QRectF(x * globals.TileWidth, y * globals.TileWidth, w * globals.TileWidth, h * globals.TileWidth)
# Update the aux thing
self.aux.TypeChange()
示例4: itemChange
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def itemChange(self, change, value):
"""
Handle movement
"""
if change == QtWidgets.QGraphicsItem.ItemPositionChange:
if self.scene() is None: return value
updRect = QtCore.QRectF(
self.x() + self.aux.x(),
self.y() + self.aux.y(),
self.aux.BoundingRect.width(),
self.aux.BoundingRect.height(),
)
self.scene().update(updRect)
return super().itemChange(change, value)
示例5: computeBoundRectAndPos
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def computeBoundRectAndPos(self):
xcoords = []
ycoords = []
for node in self.nodelist:
xcoords.append(int(node['x']) + 8)
ycoords.append(int(node['y']) + 8)
self.objx = (min(xcoords) - 4)
self.objy = (min(ycoords) - 4)
mywidth = (8 + (max(xcoords) - self.objx)) * (globals.TileWidth / 16)
myheight = (8 + (max(ycoords) - self.objy)) * (globals.TileWidth / 16)
globals.DirtyOverride += 1
self.setPos(self.objx * (globals.TileWidth / 16), self.objy * (globals.TileWidth / 16))
globals.DirtyOverride -= 1
self.prepareGeometryChange()
self.BoundingRect = QtCore.QRectF(-4, -4, mywidth, myheight)
示例6: __init__
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def __init__(self, parent, imageObj):
"""
Generic constructor for auxiliary zone items
"""
super().__init__(parent)
self.parent = parent
self.imageObj = imageObj
self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, False)
self.setParentItem(parent)
self.hover = False
if parent is not None:
parent.aux.add(self)
self.BoundingRect = QtCore.QRectF(0, 0, TileWidth, TileWidth)
示例7: diagramSizeChanged
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def diagramSizeChanged(self):
"""
Change the size of the diagram.
:rtype: QUndoCommand
"""
sceneRect = self.diagram.sceneRect()
size1 = max(sceneRect.width(), sceneRect.height())
size2 = self.diagramSizeField.value()
if size1 != size2:
items = self.diagram.items()
if items:
x = set()
y = set()
for item in items:
if item.isEdge() or item.isNode():
b = item.mapRectToScene(item.boundingRect())
x.update({b.left(), b.right()})
y.update({b.top(), b.bottom()})
size2 = max(size2, abs(min(x) * 2), abs(max(x) * 2), abs(min(y) * 2), abs(max(y) * 2))
return CommandDiagramResize(self.diagram, QtCore.QRectF(-size2 / 2, -size2 / 2, size2, size2))
return None
示例8: create
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def create(cls, name, size, project):
"""
Build and returns a new Diagram instance, using the given parameters.
:type name: str
:type size: int
:type project: Project
:rtype: Diagram
"""
diagram = Diagram(name, project)
diagram.setSceneRect(QtCore.QRectF(-size / 2, -size / 2, size, size))
diagram.setItemIndexMethod(Diagram.BspTreeIndex)
return diagram
#############################################
# PROPERTIES
#################################
示例9: visibleRect
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def visibleRect(self, margin=0):
"""
Returns a rectangle matching the area of visible items.
:type margin: float
:rtype: QtCore.QRectF
"""
items = self.items()
if items:
x = set()
y = set()
for item in items:
b = item.mapRectToScene(item.boundingRect())
x.update({b.left(), b.right()})
y.update({b.top(), b.bottom()})
return QtCore.QRectF(QtCore.QPointF(min(x) - margin, min(y) - margin), QtCore.QPointF(max(x) + margin, max(y) + margin))
return QtCore.QRectF()
示例10: __init__
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def __init__(self, width, height, color, border=None):
"""
Initialize the icon.
:type width: T <= int | float
:type height: T <= int | float
:type color: str
:type border: str
"""
pixmap = QtGui.QPixmap(width, height)
painter = QtGui.QPainter(pixmap)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
path = QtGui.QPainterPath()
path.addRect(QtCore.QRectF(QtCore.QPointF(0, 0), QtCore.QPointF(width, height)))
painter.fillPath(path, QtGui.QBrush(QtGui.QColor(color)))
if border:
painter.setPen(QtGui.QPen(QtGui.QColor(border), 0, QtCore.Qt.SolidLine))
painter.drawPath(path)
painter.end()
super().__init__(pixmap)
示例11: __init__
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def __init__(self, width=52, height=30, brush=None, inputs=None, **kwargs):
"""
Initialize the node.
:type width: int
:type height: int
:type brush: QBrush
:type inputs: DistinctList
"""
super().__init__(**kwargs)
brush = PropertyAssertionNode.DefaultBrush
pen = PropertyAssertionNode.DefaultPen
self.inputs = inputs or DistinctList()
self.background = Polygon(QtCore.QRectF(-34, -19, 68, 38))
self.selection = Polygon(QtCore.QRectF(-34, -19, 68, 38))
self.polygon = Polygon(QtCore.QRectF(-26, -15, 52, 30), brush, pen)
#############################################
# INTERFACE
#################################
示例12: _draw_textdoc
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def _draw_textdoc(self, rect, col):
"""Draw the QTextDocument of an item.
Args:
rect: The QRect to clip the drawing to.
"""
assert self._painter is not None
assert self._doc is not None
assert self._opt is not None
# We can't use drawContents because then the color would be ignored.
clip = QRectF(0, 0, rect.width(), rect.height())
self._painter.save()
if self._opt.state & QStyle.State_Selected:
color = config.cache['colors.completion.item.selected.fg']
elif not self._opt.state & QStyle.State_Enabled:
color = config.cache['colors.completion.category.fg']
else:
colors = config.cache['colors.completion.fg']
# if multiple colors are set, use different colors per column
color = colors[col % len(colors)]
self._painter.setPen(color)
ctx = QAbstractTextDocumentLayout.PaintContext()
ctx.palette.setColor(QPalette.Text, self._painter.pen().color())
if clip.isValid():
self._painter.setClipRect(clip)
ctx.clip = clip
self._doc.documentLayout().draw(self._painter, ctx)
self._painter.restore()
示例13: _breathing_gi_hover
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def _breathing_gi_hover(self):
if mc.mc_global.breathing_state == mc.mc_global.BreathingState.breathing_in:
return
hover_rectangle_qsize = QtCore.QSizeF(BR_WIDTH_FT, BR_HEIGHT_FT)
# noinspection PyCallByClass
pos_pointf = QtWidgets.QGraphicsItem.mapFromItem(
self._breathing_gi,
self._breathing_gi,
self._breathing_gi.x() + (self._breathing_gi.boundingRect().width() - hover_rectangle_qsize.width()) / 2,
self._breathing_gi.y() + (self._breathing_gi.boundingRect().height() - hover_rectangle_qsize.height()) / 2
)
# -widget coords
hover_rectangle_coords_qrect = QtCore.QRectF(pos_pointf, hover_rectangle_qsize)
cursor = QtGui.QCursor() # -screen coords
cursor_pos_widget_coords_qp = self.mapFromGlobal(cursor.pos()) # -widget coords
logging.debug("cursor.pos() = " + str(cursor.pos()))
logging.debug("cursor_pos_widget_coords_qp = " + str(cursor_pos_widget_coords_qp))
logging.debug("hover_rectangle_coords_qrect = " + str(hover_rectangle_coords_qrect))
if hover_rectangle_coords_qrect.contains(cursor_pos_widget_coords_qp):
mc.mc_global.breathing_state = mc.mc_global.BreathingState.breathing_in
self.ib_signal.emit()
self.text_gi.update_pos_and_origin_point(VIEW_WIDTH_INT, VIEW_HEIGHT_INT)
self._breathing_gi.update_pos_and_origin_point(VIEW_WIDTH_INT, VIEW_HEIGHT_INT)
示例14: __init__
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def __init__(self):
super().__init__()
self.rectf = QtCore.QRectF(0.0, 0.0, BR_WIDTH_FT, BR_HEIGHT_FT)
self.setAcceptHoverEvents(True)
# Overridden
示例15: __init__
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QRectF [as 別名]
def __init__(self, parent):
super(DefinitionsUI, self).__init__()
self.setupUi(self)
self._translate = QtCore.QCoreApplication.translate
self.parent = parent
self.previous_position = None
self.setWindowFlags(
QtCore.Qt.Popup |
QtCore.Qt.FramelessWindowHint)
radius = 15
path = QtGui.QPainterPath()
path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
try:
mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
self.setMask(mask)
except TypeError: # Required for older versions of Qt
pass
self.definitionView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.app_id = 'bb7a91f9'
self.app_key = 'fefacdf6775c347b52e9efa2efe642ef'
self.root_url = 'https://od-api.oxforddictionaries.com:443/api/v1/inflections/'
self.define_url = 'https://od-api.oxforddictionaries.com:443/api/v1/entries/'
self.pronunciation_mp3 = None
self.okButton.clicked.connect(self.hide)
self.dialogBackground.clicked.connect(self.color_background)
if multimedia_available:
self.pronounceButton.clicked.connect(self.play_pronunciation)
else:
self.pronounceButton.setEnabled(False)