當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QRectF方法代碼示例

本文整理匯總了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) 
開發者ID:SeptemberHX,項目名稱:screenshot,代碼行數:26,代碼來源:screenshot.py

示例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) 
開發者ID:HuberTRoy,項目名稱:MusicBox,代碼行數:25,代碼來源:player.py

示例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() 
開發者ID:aboood40091,項目名稱:Miyamoto,代碼行數:22,代碼來源:items.py

示例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) 
開發者ID:aboood40091,項目名稱:Miyamoto,代碼行數:18,代碼來源:items.py

示例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) 
開發者ID:aboood40091,項目名稱:Miyamoto,代碼行數:18,代碼來源:items.py

示例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) 
開發者ID:aboood40091,項目名稱:Miyamoto,代碼行數:19,代碼來源:spritelib.py

示例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 
開發者ID:danielepantaleone,項目名稱:eddy,代碼行數:23,代碼來源:properties.py

示例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
    ################################# 
開發者ID:danielepantaleone,項目名稱:eddy,代碼行數:18,代碼來源:diagram.py

示例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() 
開發者ID:danielepantaleone,項目名稱:eddy,代碼行數:18,代碼來源:diagram.py

示例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) 
開發者ID:danielepantaleone,項目名稱:eddy,代碼行數:21,代碼來源:qt.py

示例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
    ################################# 
開發者ID:danielepantaleone,項目名稱:eddy,代碼行數:21,代碼來源:property_assertion.py

示例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() 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:33,代碼來源:completiondelegate.py

示例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) 
開發者ID:mindfulness-at-the-computer,項目名稱:mindfulness-at-the-computer,代碼行數:29,代碼來源:breathing_dlg.py

示例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 
開發者ID:mindfulness-at-the-computer,項目名稱:mindfulness-at-the-computer,代碼行數:8,代碼來源:breathing_dlg.py

示例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) 
開發者ID:BasioMeusPuga,項目名稱:Lector,代碼行數:40,代碼來源:definitionsdialog.py


注:本文中的PyQt5.QtCore.QRectF方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。