Python PyQt5.QtCore.QRectF() Examples
The following are 30
code examples of PyQt5.QtCore.QRectF().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtCore
, or try the search function
.
Example #1
Source File: screenshot.py From screenshot with GNU General Public License v3.0 | 8 votes |
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)
Example #2
Source File: items.py From Miyamoto with GNU General Public License v3.0 | 6 votes |
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()
Example #3
Source File: properties.py From eddy with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: diagram.py From eddy with GNU General Public License v3.0 | 6 votes |
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 #################################
Example #5
Source File: diagram.py From eddy with GNU General Public License v3.0 | 6 votes |
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()
Example #6
Source File: qt.py From eddy with GNU General Public License v3.0 | 6 votes |
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)
Example #7
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 6 votes |
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)
Example #8
Source File: player.py From MusicBox with MIT License | 6 votes |
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)
Example #9
Source File: property_assertion.py From eddy with GNU General Public License v3.0 | 6 votes |
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 #################################
Example #10
Source File: items.py From Miyamoto with GNU General Public License v3.0 | 6 votes |
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)
Example #11
Source File: items.py From Miyamoto with GNU General Public License v3.0 | 6 votes |
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)
Example #12
Source File: items.py From Miyamoto with GNU General Public License v3.0 | 6 votes |
def computeBoundRectAndPos(self): xcoords = [] ycoords = [] for node in self.nodelist: xcoords.append(int(node['x'])) ycoords.append(int(node['y'])) 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)
Example #13
Source File: value_domain.py From eddy with GNU General Public License v3.0 | 5 votes |
def boundingRect(self): """ Returns the shape bounding rectangle. :rtype: QtCore.QRectF """ return self.selection.geometry()
Example #14
Source File: attribute.py From eddy with GNU General Public License v3.0 | 5 votes |
def updateNode(self, functional=None, **kwargs): """ Update the current node. :type functional: bool """ if functional is None: functional = self.isFunctional() # FUNCTIONAL POLYGON (SHAPE) path1 = QtGui.QPainterPath() path1.addEllipse(self.polygon.geometry()) path2 = QtGui.QPainterPath() path2.addEllipse(QtCore.QRectF(-7, -7, 14, 14)) self.fpolygon.setGeometry(path1.subtracted(path2)) # FUNCTIONAL POLYGON (PEN & BRUSH) pen = QtGui.QPen(QtCore.Qt.NoPen) brush = QtGui.QBrush(QtCore.Qt.NoBrush) if functional: pen = QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin) brush = QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)) self.fpolygon.setPen(pen) self.fpolygon.setBrush(brush) # SELECTION + BACKGROUND + CACHE REFRESH super().updateNode(**kwargs)
Example #15
Source File: individual.py From eddy with GNU General Public License v3.0 | 5 votes |
def boundingRect(self): """ Returns the shape bounding rectangle. :rtype: QtCore.QRectF """ path = QtGui.QPainterPath() path.addPolygon(self.selection.geometry()) return path.boundingRect()
Example #16
Source File: property_assertion.py From eddy with GNU General Public License v3.0 | 5 votes |
def boundingRect(self): """ Returns the shape bounding rectangle. :rtype: QtCore.QRectF """ return self.selection.geometry()
Example #17
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def setSize(self, width, height, xoff=0, yoff=0): self.prepareGeometryChange() self.BoundingRect = QtCore.QRectF(0, 0, width, height) self.setPos(xoff, yoff) self.width = width self.height = height
Example #18
Source File: value_domain.py From eddy with GNU General Public License v3.0 | 5 votes |
def updateNode(self, *args, **kwargs): """ Update the current node. """ # POLYGON + BACKGROUND + SELECTION (GEOMETRY) width = max(self.label.width() + 16, 90) self.polygon.setGeometry(QtCore.QRectF(-width / 2, -20, width, 40)) self.background.setGeometry(QtCore.QRectF(-(width + 8) / 2, -24, width + 8, 48)) self.selection.setGeometry(QtCore.QRectF(-(width + 8) / 2, -24, width + 8, 48)) self.updateTextPos() self.updateEdges() # SELECTION + BACKGROUND + CACHE REFRESH super().updateNode(**kwargs)
Example #19
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def setSize(self, width, height, xoff=0, yoff=0): self.BoundingRect = QtCore.QRectF(0, 0, width, height) self.setPos(xoff, yoff)
Example #20
Source File: items.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def CreateTextEdit(self): """ Make the text edit """ self.TextEdit = QtWidgets.QPlainTextEdit() self.TextEditProxy = globals.mainWindow.scene.addWidget(self.TextEdit) self.TextEditProxy.setZValue(self.zval) self.TextEditProxy.setCursor(Qt.IBeamCursor) self.TextEditProxy.boundingRect = lambda self: QtCore.QRectF(0, 0, 4000, 4000) self.TextEdit.setVisible(False) self.TextEdit.setMinimumWidth(8 * globals.TileWidth) self.TextEdit.setMinimumHeight(16 * globals.TileWidth / 3) self.TextEdit.setMaximumWidth(8 * globals.TileWidth) self.TextEdit.setMaximumHeight(16 * globals.TileWidth / 3) self.TextEdit.setPlainText(self.text) self.TextEdit.textChanged.connect(self.handleTextChanged) self.TextEdit.zoomIn(13) self.reposTextEdit()
Example #21
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, path, width, height, xoff=0, yoff=0): """ Constructor """ super().__init__(parent) self.PainterPath = path self.setPos(xoff, yoff) self.fillFlag = True self.BoundingRect = QtCore.QRectF(0, 0, width, height) self.hover = False
Example #22
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def setSize(self, width, height, xoff=0, yoff=0): self.BoundingRect = QtCore.QRectF(0, 0, width, height) self.setPos(xoff, yoff)
Example #23
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, width, height, xoff=0, yoff=0): """ Constructor """ super().__init__(parent) self.BoundingRect = QtCore.QRectF(0, 0, width, height) self.setPos(xoff, yoff) self.hover = False
Example #24
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, width): """ Constructor """ super().__init__(parent) self.BoundingRect = QtCore.QRectF(0, 0, width * (TileWidth/16), width * (TileWidth/16)) self.setPos((8 - (width / 2)) * (TileWidth/16), (8 - (width / 2)) * (TileWidth/16)) self.width = width self.startAngle = 0 self.spanAngle = 0 self.hover = False
Example #25
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def setSize(self, width, height): self.prepareGeometryChange() self.BoundingRect = QtCore.QRectF(0, 0, width * (TileWidth/16), height * (TileWidth/16)) self.width = width self.height = height
Example #26
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, width, height, direction): """ Constructor """ super().__init__(parent) self.BoundingRect = QtCore.QRectF(0, 0, width * (TileWidth/16), height * (TileWidth/16)) self.setPos(0, 0) self.width = width self.height = height self.direction = direction self.hover = False
Example #27
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent): """ Generic constructor for auxiliary items """ super().__init__(parent) self.parent = parent self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False) self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False) self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, True) self.setParentItem(parent) self.hover = False self.BoundingRect = QtCore.QRectF(0, 0, TileWidth, TileWidth)
Example #28
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def getBR(self): return QtCore.QRectF( self.xOffset * self.scale, self.yOffset * self.scale, self.width * self.scale, self.height * self.scale, )
Example #29
Source File: spritelib.py From Miyamoto with GNU General Public License v3.0 | 5 votes |
def getRR(self): return QtCore.QRectF( self.xOffset * self.scale + 1, self.yOffset * self.scale + 1, self.width * self.scale - 2, self.height * self.scale - 2, )
Example #30
Source File: operator.py From eddy with GNU General Public License v3.0 | 5 votes |
def boundingRect(self): """ Returns the shape bounding rectangle. :rtype: QtCore.QRectF """ path = QtGui.QPainterPath() path.addPolygon(self.selection.geometry()) return path.boundingRect()