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


Python QtCore.QRectF方法代碼示例

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


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

示例1: draw_ranges

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def draw_ranges(self) -> None:
        """Draw rectangle ranges."""
        pen = QPen()
        pen.setWidth(5)
        for i, (tag, rect) in enumerate(self.ranges.items()):
            range_color = QColor(color_num(i + 1))
            range_color.setAlpha(30)
            self.painter.setBrush(range_color)
            range_color.setAlpha(255)
            pen.setColor(range_color)
            self.painter.setPen(pen)
            cx = rect.x() * self.zoom
            cy = rect.y() * -self.zoom
            if rect.width():
                self.painter.drawRect(QRectF(
                    QPointF(cx, cy),
                    QSizeF(rect.width(), rect.height()) * self.zoom
                ))
            else:
                self.draw_circle(QPointF(cx, cy), 3)
            range_color.setAlpha(255)
            pen.setColor(range_color)
            self.painter.setPen(pen)
            self.painter.drawText(QPointF(cx, cy) + QPointF(6, -6), tag)
            self.painter.setBrush(Qt.NoBrush) 
開發者ID:KmolYuan,項目名稱:Pyslvs-UI,代碼行數:27,代碼來源:canvas.py

示例2: boundingRect

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def boundingRect(self):
        srcPoint = self.mapFromScene(self.__srcPortCircle.centerInSceneCoords())
        dstPoint = self.mapFromScene(self.__dstPortCircle.centerInSceneCoords())
        penWidth = self.__defaultPen.width()

        return QtCore.QRectF(
            min(srcPoint.x(), dstPoint.x()),
            min(srcPoint.y(), dstPoint.y()),
            abs(dstPoint.x() - srcPoint.x()),
            abs(dstPoint.y() - srcPoint.y()),
            ).adjusted(-penWidth/2, -penWidth/2, +penWidth/2, +penWidth/2) 
開發者ID:EricTRocks,項目名稱:pyflowgraph,代碼行數:13,代碼來源:connection.py

示例3: generatePicture

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def generatePicture(self,data=None,redraw=False):
        """重新生成圖形對象"""
        # 重畫或者隻更新最後一個K線
        if redraw:
            self.pictures = []
        elif self.pictures:
            self.pictures.pop()
        w = 0.4
        bPen   = self.bPen
        bBrush = self.bBrush
        rPen   = self.rPen
        rBrush = self.rBrush
        self.low,self.high = (np.min(data['low']),np.max(data['high'])) if len(data)>0 else (0,1)
        npic = len(self.pictures)
        for (t, open0, close0, low0, high0) in data:
            if t >= npic:
                picture = QtGui.QPicture()
                p = QtGui.QPainter(picture)
                # 下跌藍色(實心), 上漲紅色(空心)
                pen,brush,pmin,pmax = (bPen,bBrush,close0,open0)\
                    if open0 > close0 else (rPen,rBrush,open0,close0)
                p.setPen(pen)  
                p.setBrush(brush)
                # 畫K線方塊和上下影線
                if open0 == close0:
                    p.drawLine(QtCore.QPointF(t-w,open0), QtCore.QPointF(t+w, close0))
                else:
                    p.drawRect(QtCore.QRectF(t-w, open0, w*2, close0-open0))
                if pmin  > low0:
                    p.drawLine(QtCore.QPointF(t,low0), QtCore.QPointF(t, pmin))
                if high0 > pmax:
                    p.drawLine(QtCore.QPointF(t,pmax), QtCore.QPointF(t, high0))
                p.end()
                self.pictures.append(picture)

    # 手動重畫
    #---------------------------------------------------------------------- 
開發者ID:rjj510,項目名稱:uiKLine,代碼行數:39,代碼來源:uiKLine.py

示例4: boundingRect

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def boundingRect(self):
        return QtCore.QRectF(0,self.low,len(self.pictures),(self.high-self.low))
    
    #---------------------------------------------------------------------- 
開發者ID:rjj510,項目名稱:uiKLine,代碼行數:6,代碼來源:uiKLine.py

示例5: boundingRect

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def boundingRect(self):
        return QtCore.QRectF(0,self.low,len(self.pictures),(self.high-self.low))


######################################################################## 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:7,代碼來源:uiKLine.py

示例6: to_rect

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def to_rect(self, zoom: float) -> QRectF:
        """Return limit as QRectF type."""
        return QRectF(
            QPointF(self.x, -self.y) * zoom,
            QPointF(self.sx, -self.sy) * zoom
        ) 
開發者ID:KmolYuan,項目名稱:Pyslvs-UI,代碼行數:8,代碼來源:canvas_base.py

示例7: __draw_link

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def __draw_link(self, vlink: VLink) -> None:
        """Draw a link."""
        if vlink.name == VLink.FRAME or not vlink.points:
            return
        pen = QPen()
        # Rearrange: Put the nearest point to the next position.
        qpoints = convex_hull(
            [(c.x * self.zoom, c.y * -self.zoom)
             for c in vlink.points_pos(self.vpoints)], as_qpoint=True)
        if (
            self.select_mode == SelectMode.LINK
            and self.vlinks.index(vlink) in self.selections
        ):
            pen.setWidth(self.link_width + 6)
            pen.setColor(Qt.black if self.monochrome else QColor(161, 16, 239))
            self.painter.setPen(pen)
            self.painter.drawPolygon(*qpoints)
        pen.setWidth(self.link_width)
        pen.setColor(Qt.black if self.monochrome else QColor(*vlink.color))
        self.painter.setPen(pen)
        self.painter.drawPolygon(*qpoints)
        if not self.show_point_mark:
            return
        pen.setColor(Qt.darkGray)
        self.painter.setPen(pen)
        p_count = len(qpoints)
        cen_x = sum(p.x() for p in qpoints) / p_count
        cen_y = sum(p.y() for p in qpoints) / p_count
        self.painter.drawText(
            QRectF(cen_x - 50, cen_y - 50, 100, 100),
            Qt.AlignCenter,
            f'[{vlink.name}]'
        ) 
開發者ID:KmolYuan,項目名稱:Pyslvs-UI,代碼行數:35,代碼來源:canvas_base.py

示例8: adjust_drawing

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def adjust_drawing(self):
        """
        When the user resizes the window, the drawing elements follow the x-positions of the corresponding
        attribute_widgets.
        """

        for item in self.graphic_items:
            item.move_to_right_position()
        for conn in self.connections:
            conn.adjust()
        iq = self.module_widgets[0]

        for index, prop in enumerate(["input", "acbandwidth", "frequency",
                                      "bandwidth", "quadrature_factor", "gain",
                                      "amplitude", "output_direct"][::2]):
            widget = iq.attribute_widgets[prop]
            self.frames[index].setFixedSize(widget.width() + iq.main_layout.spacing(), self.height())
            self.frames[index].move(widget.x() + iq.pos().x() - iq.main_layout.spacing() / 2, 0)

            self.frames_drawing[index].setFixedSize(widget.width() + iq.main_layout.spacing(), self.height())
            self.frames_drawing[index].move(widget.x() + iq.pos().x() - self.view.pos().x() - iq.main_layout.spacing() / 2,
                                            0)
        self.scene.setSceneRect(QtCore.QRectF(self.view.rect()))
        #x, y = self.view.pos().x(), self.view.pos().y()
        button_width = 150
        self.button_hide.move(self.width()/2 - button_width/2, self.height() - 17)
        self.button_hide.setFixedWidth(button_width)
        self.button_hide.raise_() 
開發者ID:lneuhaus,項目名稱:pyrpl,代碼行數:30,代碼來源:module_manager_widget.py

示例9: generatePicture

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def generatePicture(self,data=None,redraw=False):
        """重新生成圖形對象"""
        # 重畫或者隻更新最後一個K線
        if redraw:
            self.pictures = []
        elif self.pictures:
            self.pictures.pop()
        w = 0.4
        bPen   = self.bPen
        bBrush = self.bBrush
        rPen   = self.rPen
        rBrush = self.rBrush
        low,high = (data[0]['low'],data[0]['high']) if len(data)>0 else (0,1)
        for (t, open0, close0, low0, high0) in data:
            # t 並不是時間,是序列
            if t >= len(self.pictures):
                # 每一個K線創建一個picture
                picture = QtGui.QPicture()
                p = QtGui.QPainter(picture)
                low, high = (min(low, low0), max(high, high0))

                # 下跌藍色(實心), 上漲紅色(空心)
                pen, brush, pmin, pmax = (bPen, bBrush, close0, open0)\
                    if open0 > close0 else (rPen, rBrush, open0, close0)
                p.setPen(pen)  
                p.setBrush(brush)

                # 畫K線方塊和上下影線
                if open0 == close0:
                    p.drawLine(QtCore.QPointF(t-w,open0), QtCore.QPointF(t+w, close0))
                else:
                    p.drawRect(QtCore.QRectF(t-w, open0, w*2, close0-open0))
                if pmin  > low0:
                    p.drawLine(QtCore.QPointF(t,low0), QtCore.QPointF(t, pmin))
                if high0 > pmax:
                    p.drawLine(QtCore.QPointF(t,pmax), QtCore.QPointF(t, high0))

                p.end()
                # 添加到隊列中
                self.pictures.append(picture)

        # 更新所有K線的最高/最低
        self.low,self.high = low,high

    # 手動重畫
    #---------------------------------------------------------------------- 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:48,代碼來源:uiKLine.py

示例10: __init__

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def __init__(
        self,
        mechanism: Dict[str, Any],
        path: Sequence[Sequence[_Coord]],
        vpoints: List[VPoint] = None,
        vlinks: List[VLink] = None,
        parent: QWidget = None
    ):
        """Input link and path data."""
        super(_DynamicCanvas, self).__init__(parent)
        self.mechanism = mechanism
        self.vpoints = vpoints or []
        self.vlinks = vlinks or []
        self.no_mechanism = not self.vpoints or not self.vlinks
        use_norm = self.no_mechanism and (
            self.mechanism.get('shape_only', False)
            or self.mechanism.get('wavelet_mode', False))
        # Target path
        same: Dict[int, int] = self.mechanism['same']
        target_path: _TargetPath = self.mechanism['target']
        for i, p in target_path.items():
            for j in range(i):
                if j in same:
                    i -= 1
            self.target_path[i] = norm_path(p) if use_norm else p
        self.path.path = []
        for i, p in enumerate(path):
            if i in self.target_path and use_norm:
                self.path.path.append(norm_path(efd_fitting(p)))
            else:
                self.path.path.append(p)
        self.__index = 0
        self.__interval = 1
        self.__path_count = max(len(path) for path in self.path.path) - 1
        self.pos = []
        # Error
        self.error = False
        self.__no_error = 0
        if self.no_mechanism:
            return
        # Ranges
        ranges: Dict[int, _Range] = self.mechanism['placement']
        self.ranges.update({f"P{i}": QRectF(
            QPointF(values[0] - values[2], values[1] + values[2]),
            QSizeF(values[2] * 2, values[2] * 2)
        ) for i, values in ranges.items()})
        # Timer
        self.__timer = QTimer()
        self.__timer.timeout.connect(self.__change_index)
        self.__timer.start(18) 
開發者ID:KmolYuan,項目名稱:Pyslvs-UI,代碼行數:52,代碼來源:preview.py

示例11: paintEvent

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QRectF [as 別名]
def paintEvent(self, event: QPaintEvent) -> None:
        """Using a QPainter under 'self',
        so just change QPen or QBrush before painting.
        """
        if not self.__grab_mode:
            self.painter.begin(self)
            self.painter.fillRect(event.rect(), QBrush(Qt.white))
        # Translation
        self.painter.translate(self.ox, self.oy)
        # Background
        if not self.background.isNull():
            rect = self.background.rect()
            self.painter.setOpacity(self.background_opacity)
            self.painter.drawImage(QRectF(
                self.background_offset * self.zoom,
                QSizeF(rect.width(), rect.height())
                * self.background_scale * self.zoom
            ), self.background, QRectF(rect))
            self.painter.setOpacity(1)
        # Show frame
        pen = QPen(Qt.blue)
        pen.setWidth(1)
        self.painter.setPen(pen)
        self.painter.setFont(QFont("Arial", self.font_size))
        # Draw origin lines
        if self.show_ticks not in {_TickMark.SHOW, _TickMark.SHOW_NUM}:
            return
        pen.setColor(Qt.gray)
        self.painter.setPen(pen)
        x_l = -self.ox
        x_r = self.width() - self.ox
        self.painter.drawLine(QPointF(x_l, 0), QPointF(x_r, 0))
        y_t = self.height() - self.oy
        y_b = -self.oy
        self.painter.drawLine(QPointF(0, y_b), QPointF(0, y_t))

        def indexing(v: float) -> int:
            """Draw tick."""
            return int(v / self.zoom - v / self.zoom % 5)

        # Draw tick
        for x in range(indexing(x_l), indexing(x_r) + 1, 5):
            if x == 0:
                continue
            is_ten = x % 10 == 0
            end = QPointF(x * self.zoom, -10 if is_ten else -5)
            self.painter.drawLine(QPointF(x, 0) * self.zoom, end)
            if self.show_ticks == _TickMark.SHOW_NUM and is_ten:
                self.painter.drawText(end + QPointF(0, 3), f"{x}")
        for y in range(indexing(y_b), indexing(y_t) + 1, 5):
            if y == 0:
                continue
            is_ten = y % 10 == 0
            end = QPointF(10 if is_ten else 5, y * self.zoom)
            self.painter.drawLine(QPointF(0, y) * self.zoom, end)
            if self.show_ticks == _TickMark.SHOW_NUM and is_ten:
                self.painter.drawText(end + QPointF(3, 0), f"{-y}")
        # Please to call the "end" method when ending paint event. 
開發者ID:KmolYuan,項目名稱:Pyslvs-UI,代碼行數:60,代碼來源:canvas.py


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