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


Python QtCore.QRect方法代碼示例

本文整理匯總了Python中PySide2.QtCore.QRect方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QRect方法的具體用法?Python QtCore.QRect怎麽用?Python QtCore.QRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PySide2.QtCore的用法示例。


在下文中一共展示了QtCore.QRect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sampleLatentAtPos

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def sampleLatentAtPos(self, pos):
		imgRect = self.getImageDims()
		gridDims = self.gridSize #self.latentSize *
		w = int(imgRect.width() / self.gridSize.width()) #self.latentSize * ( #self.getCurrentLatentWidth()
		h_l = self.latentSize // 2

		self.sampledLatentPos = self.getGridCoords(pos)

		posGrid = self.sampledLatentPos - QPoint(h_l, h_l)
		posGrid.setX(min(max(posGrid.x(), 0), gridDims.width() - h_l))
		posGrid.setY(min(max(posGrid.y(), 0), gridDims.height() - h_l))

		posImg = QPoint(int(imgRect.width() * posGrid.x() / gridDims.width()), int(imgRect.height() * posGrid.y() / gridDims.height()))

		fullImg = self._image.pixmap()
		imgRegion = fullImg.copy(QRect(posImg, QSize(w, w))).toImage()

		region_array = np.ndarray(shape=(imgRegion.height(), imgRegion.width(), 4), dtype=np.uint8, buffer=imgRegion.bits())
		self.sampledLatent = region_array[:, :, [2, 1, 0]] #BGR -> RGB 
開發者ID:afruehstueck,項目名稱:tileGAN,代碼行數:21,代碼來源:tileGAN_client.py

示例2: test_level

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def test_level(level_info, qtbot):
    *level_info, transparent = level_info
    level_ref = LevelRef()
    level_ref.load_level(*level_info)

    Block._block_cache.clear()

    # monkeypatch level names, since the level name data is broken atm
    level_ref.level.name = current_test_name()

    level_view = LevelView(None, level_ref, ContextMenu(level_ref))
    level_view.transparency = transparent
    level_view.draw_jumps = False
    level_view.draw_grid = False
    level_view.draw_autoscroll = True

    rect = QRect(QPoint(0, 0), QSize(*level_ref.level.size) * 16)

    level_view.setGeometry(rect)

    _test_level_against_reference(level_view, qtbot) 
開發者ID:mchlnix,項目名稱:SMB3-Foundry,代碼行數:23,代碼來源:test_level_drawing.py

示例3: _set_window_geometry

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def _set_window_geometry(self):
        """
        Loads stored window geometry preferences and applies them to the QWindow.
        .setGeometry() sets the size of the window minus the window frame.
        For this reason it should be set on self.blender_widget.
        """

        settings = QSettings('Tech-Artists.org', 'Blender Qt Wrapper')
        settings.beginGroup(self._settings_key_window_group_name)

        if settings.value(self._settings_key_full_screen, 'false').lower() == 'true':
            self.blender_widget.showFullScreen()
            return

        if settings.value(self._settings_key_maximized, 'false').lower() == 'true':
            self.blender_widget.showMaximized()
            return

        self.blender_widget.setGeometry(settings.value(self._settings_key_geometry, QRect(0, 0, 640, 480)))
        self.blender_widget.show()

        settings.endGroup()
        return 
開發者ID:techartorg,項目名稱:bqt,代碼行數:25,代碼來源:blender_application.py

示例4: _create_major_item_boxes

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def _create_major_item_boxes(self, item_database: ItemDatabase):
        for major_item in item_database.major_items.values():
            if major_item.required or major_item.item_category == ItemCategory.ENERGY_TANK:
                continue
            category_box, category_layout, elements = self._boxes_for_category[major_item.item_category]

            item_button = QToolButton(category_box)
            item_button.setGeometry(QRect(20, 30, 24, 21))
            item_button.setText("...")

            item_label = QLabel(category_box)
            item_label.setText(major_item.name)

            i = len(elements)
            category_layout.addWidget(item_button, i, 0)
            category_layout.addWidget(item_label, i, 1)
            elements[major_item] = item_button, item_label

            item_button.clicked.connect(partial(self.show_item_popup, major_item)) 
開發者ID:randovania,項目名稱:randovania,代碼行數:21,代碼來源:main_rules.py

示例5: show_instruction

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def show_instruction(self, insn_addr, insn_pos=None, centering=False, use_block_pos=False):
        block = self._insaddr_to_block.get(insn_addr, None)  # type: QGraphBlock
        if block is not None:
            if use_block_pos:
                x, y = block.mapToScene(block.x(), block.y())
            else:
                pos = block.mapToScene(*block.instruction_position(insn_addr))
                x, y = pos.x(), pos.y()

            if not centering:
                # is it visible?
                viewport = self.viewport()
                visible_area = self.mapToScene(QRect(0, 0, viewport.width(), viewport.height())).boundingRect()
                topx = visible_area.x()
                topy = visible_area.y()
                if topx <= x < topx + visible_area.width() and topy <= y < topy + visible_area.height():
                    return

            # make it visible in the center
            self.centerOn(x, y) 
開發者ID:angr,項目名稱:angr-management,代碼行數:22,代碼來源:qdisasm_graph.py

示例6: show_instruction

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def show_instruction(self, insn_addr, insn_pos=None, centering=False, use_block_pos=False):
        """

        :param insn_addr:
        :param QGraphicsItem item:
        :param centering:
        :param use_block_pos:
        :return:
        """

        if insn_pos is not None:
            # check if item is already visible in the viewport
            viewport = self._viewer.viewport()
            rect = self._viewer.mapToScene(QRect(0, 0, viewport.width(), viewport.height())).boundingRect()
            if rect.contains(insn_pos):
                return

        self.navigate_to_addr(insn_addr) 
開發者ID:angr,項目名稱:angr-management,代碼行數:20,代碼來源:qlinear_viewer.py

示例7: __init__

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def __init__(self, parent=None):
        super(SlippyMap, self).__init__(parent)

        self._offset = QPoint()
        self._tilesRect = QRect()
        self._tilePixmaps = {}  # Point(x, y) to QPixmap mapping
        self._manager = QNetworkAccessManager()
        self._url = QUrl()
        # public vars
        self.width = 400
        self.height = 300
        self.zoom = 15
        self.latitude = 59.9138204
        self.longitude = 10.7387413

        self._emptyTile = QPixmap(TDIM, TDIM)
        self._emptyTile.fill(Qt.lightGray)

        self.request = QNetworkRequest()
        self.cache = QNetworkDiskCache()
        self.cache.setCacheDirectory(QStandardPaths.writableLocation(QStandardPaths.CacheLocation))
        self._manager.setCache(self.cache)
        self._manager.finished.connect(self.handleNetworkData) 
開發者ID:SanPen,項目名稱:GridCal,代碼行數:25,代碼來源:lightmap.py

示例8: __init__

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def __init__(self, parent=None):
        super(ColorWheel, self).__init__(parent)
        self._is_clicked = False
        self._rect = QtCore.QRect(25, 25, 50, 50)
        self._current_color = QtGui.QColor(WHITE)
        self._color_point = QtCore.QPoint(150, 50)
        self._current_tool = None
        self._angle = 180
        self.setFixedSize(100, 100)
        self.initUI() 
開發者ID:luckylyk,項目名稱:hotbox_designer,代碼行數:12,代碼來源:colorwheel.py

示例9: synchronize_image

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def synchronize_image(self):
        self.pixmap = QtGui.QPixmap(self.options['image.path'])
        if self.options['image.fit'] is True:
            self.image_rect = None
            return
        self.image_rect = QtCore.QRect(
            self.rect.left(),
            self.rect.top(),
            self.options['image.width'],
            self.options['image.height'])
        self.image_rect.moveCenter(self.rect.center().toPoint()) 
開發者ID:luckylyk,項目名稱:hotbox_designer,代碼行數:13,代碼來源:interactive.py

示例10: proportional_rect

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def proportional_rect(rect, percent=None):
    """ return a scaled rect with a percentage """
    factor = float(percent) / 100
    width = rect.width() * factor
    height = rect.height() * factor
    left = rect.left() + round((rect.width() - width) / 2)
    top = rect.top() + round((rect.height() - height) / 2)
    return QtCore.QRect(left, top, width, height) 
開發者ID:luckylyk,項目名稱:hotbox_designer,代碼行數:10,代碼來源:geometry.py

示例11: mousePressEvent

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def mousePressEvent(self, event):
        """Re-implement QGraphicsView's mousePressEvent handler"""

        # status of CTRL key
        ctrl = event.modifiers() == QtCore.Qt.ControlModifier

        # if a mouse event happens in the graphics view
        # put the keyboard focus to the view as well
        self.setFocus()

        self.origin = event.pos()

        # do rubberband zoom only with left mouse button
        if event.button() == QtCore.Qt.LeftButton:

            self._leftMousePressed = True
            self._dragPos = event.pos()

            if ctrl:
                self.setCursor(QtCore.Qt.ClosedHandCursor)
            else:
                # initiate rubberband origin and size (zero at first)
                self.rubberband.setGeometry(QtCore.QRect(self.origin,
                    QtCore.QSize()))
                # show, even at zero size
                # allows to check later using isVisible()
                self.rubberband.show()

        # call corresponding base class method
        super().mousePressEvent(event) 
開發者ID:chiefenne,項目名稱:PyAero,代碼行數:32,代碼來源:GraphicsView.py

示例12: mouseMoveEvent

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def mouseMoveEvent(self, event):
        """Re-implement QGraphicsView's mouseMoveEvent handler"""

        # if a mouse event happens in the graphics view
        # put the keyboard focus to the view as well
        self.setFocus()

        # status of CTRL key
        ctrl = event.modifiers() == QtCore.Qt.ControlModifier

        # pan the view with the left mouse button and CRTL down
        if self._leftMousePressed and ctrl:
            self.setCursor(QtCore.Qt.ClosedHandCursor)
            newPos = event.pos()
            diff = newPos - self._dragPos
            self._dragPos = newPos

            # this actually does the pan
            # no matter if scroll bars are displayed or not
            self.horizontalScrollBar().setValue(
                self.horizontalScrollBar().value() - diff.x())
            self.verticalScrollBar().setValue(
                self.verticalScrollBar().value() - diff.y())

        if self.rubberband.isVisible() and not ctrl:
            self.setInteractive(False)
            self.rubberband.setGeometry(
                QtCore.QRect(self.origin, event.pos()).normalized())

        # call corresponding base class method
        super().mouseMoveEvent(event) 
開發者ID:chiefenne,項目名稱:PyAero,代碼行數:33,代碼來源:GraphicsView.py

示例13: adjustMarkerSize

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def adjustMarkerSize(self):
        """Adjust marker size during zoom. Marker items are circles
        which are otherwise affected by zoom. Using MARKERSIZE from
        Settings a fixed markersize (e.g. 3 pixels) can be kept.
        This method immitates the behaviour of pen.setCosmetic()
        """

        if not self.parent.airfoil:
            return

        # markers are drawn in GraphicsItem using scene coordinates
        # in order to keep them constant size, also when zooming
        # a fixed pixel size (MARKERSIZE from settings) is mapped to
        # scene coordinates
        # depending on the zoom, this leads to always different
        # scene coordinates
        # map a square with side length of MARKERSIZE to the scene coords
        mappedMarker = self.mapToScene(
            QtCore.QRect(0, 0, MARKERSIZE, MARKERSIZE))
        mappedMarkerWidth = mappedMarker.boundingRect().width()

        if self.parent.airfoil.contourPolygon:
            markers = self.parent.airfoil.polygonMarkers
            x, y = self.parent.airfoil.raw_coordinates
            for i, marker in enumerate(markers):
                # in case of circle, args is a QRectF
                marker.args = [QtCore.QRectF(x[i] - mappedMarkerWidth,
                                             y[i] - mappedMarkerWidth,
                                             2. * mappedMarkerWidth,
                                             2. * mappedMarkerWidth)]

        # if self.parent.airfoil.contourSpline:
        if hasattr(self.parent.airfoil, 'contourSpline'):
            markers = self.parent.airfoil.splineMarkers
            x, y = self.parent.airfoil.spline_data[0]
            for i, marker in enumerate(markers):
                # in case of circle, args is a QRectF
                marker.args = [QtCore.QRectF(x[i] - mappedMarkerWidth,
                                             y[i] - mappedMarkerWidth,
                                             2. * mappedMarkerWidth,
                                             2. * mappedMarkerWidth)] 
開發者ID:chiefenne,項目名稱:PyAero,代碼行數:43,代碼來源:GraphicsView.py

示例14: get_rect

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def get_rect(self, block_length: int = 1):
        width, height = self.size

        return QRect(QPoint(0, 0), QSize(width, height) * block_length) 
開發者ID:mchlnix,項目名稱:SMB3-Foundry,代碼行數:6,代碼來源:Level.py

示例15: numberbarPaint

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QRect [as 別名]
def numberbarPaint(self, number_bar, event):
            font_metrics = self.fontMetrics()
            current_line = self.document().findBlock(self.textCursor().position()).blockNumber() + 1
 
            block = self.firstVisibleBlock()
            line_count = block.blockNumber()
            painter = QtGui.QPainter(number_bar)
            painter.fillRect(event.rect(), self.palette().base())
 
            # Iterate over all visible text blocks in the document.
            while block.isValid():
                line_count += 1
                block_top = self.blockBoundingGeometry(block).translated(self.contentOffset()).top()
 
                # Check if the position of the block is out side of the visible
                # area.
                if not block.isVisible() or block_top >= event.rect().bottom():
                    break
 
                # We want the line number for the selected line to be bold.
                if line_count == current_line:
                    font = painter.font()
                    font.setBold(True)
                    painter.setFont(font)
                else:
                    font = painter.font()
                    font.setBold(False)
                    painter.setFont(font)
 
                # Draw the line number right justified at the position of the line.
                paint_rect = QtCore.QRect(0, block_top, number_bar.width(), font_metrics.height())
                painter.drawText(paint_rect, QtCore.Qt.AlignRight, unicode(line_count))
 
                block = block.next()
 
            painter.end() 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:38,代碼來源:LNTextEdit.py


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