当前位置: 首页>>代码示例>>Python>>正文


Python QPen.setStyle方法代码示例

本文整理汇总了Python中AnyQt.QtGui.QPen.setStyle方法的典型用法代码示例。如果您正苦于以下问题:Python QPen.setStyle方法的具体用法?Python QPen.setStyle怎么用?Python QPen.setStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnyQt.QtGui.QPen的用法示例。


在下文中一共展示了QPen.setStyle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __updatePen

# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setStyle [as 别名]
    def __updatePen(self):
        self.prepareGeometryChange()
        self.__boundingRect = None
        if self.__dynamic:
            if self.__dynamicEnabled:
                color = QColor(0, 150, 0, 150)
            else:
                color = QColor(150, 0, 0, 150)

            normal = QPen(QBrush(color), 2.0)
            hover = QPen(QBrush(color.darker(120)), 2.1)
        else:
            normal = QPen(QBrush(QColor("#9CACB4")), 2.0)
            hover = QPen(QBrush(QColor("#7D7D7D")), 2.1)

        if self.__state & LinkItem.Empty:
            pen_style = Qt.DashLine
        else:
            pen_style = Qt.SolidLine

        normal.setStyle(pen_style)
        hover.setStyle(pen_style)

        if self.hover:
            pen = hover
        else:
            pen = normal

        self.curveItem.setPen(pen)
开发者ID:PrimozGodec,项目名称:orange3,代码行数:31,代码来源:linkitem.py

示例2: shape

# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setStyle [as 别名]
 def shape(self):
     if self.__shape is None:
         path = self.curvePath()
         pen = QPen(self.pen())
         pen.setWidthF(max(pen.widthF(), 7.0))
         pen.setStyle(Qt.SolidLine)
         self.__shape = stroke_path(path, pen)
     return self.__shape
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:10,代码来源:linkitem.py

示例3: __init__

# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setStyle [as 别名]
class GraphAttributes:
    """
    Creates entire graph of explanations, paint function is the main one, it delegates painting of attributes to draw_attribute, 
    header and scale are dealt with in draw_header_footer. Header is fixed in size.

    Parameters
    ----------
    scene: QGraphicsScene
        scene to add elements to
    num_of_atr : int
        number of attributes to plot
    space: int
        space between columns with atr names, values
    offset_y : int
        distance between the line border of attribute box plot and the box itself
    rect_height : int
        height of a rectangle, representing score of the attribute
    """

    def __init__(self, scene, num_of_atr=3, space=35, offset_y=10, rect_height=40):
        self.scene = scene
        self.num_of_atr = num_of_atr
        self.space = space
        self.graph_space = 80
        self.offset_y = offset_y
        self.black_pen = QPen(Qt.black, 2)
        self.gray_pen = QPen(Qt.gray, 1)
        self.light_gray_pen = QPen(QColor("#DFDFDF"), 1)
        self.light_gray_pen.setStyle(Qt.DashLine)
        self.brush = QBrush(QColor(0x33, 0x88, 0xff, 0xc0))
        self.blue_pen = QPen(QBrush(QColor(0x33, 0x00, 0xff)), 2)
        """placeholders"""
        self.rect_height = rect_height
        self.max_contrib = None
        self.atr_area_h = None
        self.atr_area_w = None
        self.scale = None

    def get_needed_offset(self, explanations):
        max_n = 0
        word = ""
        max_v = 0
        val = ""
        for e in explanations:
            if max_n < len(str(e._metas[0])):
                word = str(e._metas[0])
                max_n = len(str(e._metas[0]))
            if max_v < len(str(e._metas[1])):
                val = str(e._metas[1])
                max_v = len(str(e._metas[1]))
        w = QGraphicsSimpleTextItem(word, None)
        v = QGraphicsSimpleTextItem(val, None)
        return w.boundingRect().width(), v.boundingRect().width()

    def paint(self, wp, explanations=None, header_h=100):
        """
        Coordinates drawing
        Parameters
        ----------
        wp : QWidget
            current viewport
        explanations : Orange.data.table
            data table with name, value, score and error of attributes to plot
        header_h : int
            space to be left on the top and the bottom of graph for header and scale
        """
        self.name_w, self.val_w = self.get_needed_offset(explanations)
        self.offset_left = self.space + self.name_w + \
            self.space + self.val_w + self.graph_space
        self.offset_right = self.graph_space + 50

        self.atr_area_h = wp.height()/2 - header_h
        self.atr_area_w = (wp.width() - self.offset_left -
                           self.offset_right) / 2

        coords = self.split_boxes_area(
            self.atr_area_h, self.num_of_atr, header_h)
        self.max_contrib = np.max(
            abs(explanations.X[:, 0]) + explanations.X[:, 1])
        self.unit = self.get_scale()
        unit_pixels = np.floor(self.atr_area_w/(self.max_contrib/self.unit))
        self.scale = unit_pixels / self.unit

        self.draw_header_footer(
            wp, header_h, unit_pixels, coords[self.num_of_atr - 1], coords[0])

        for y, e in zip(coords, explanations[:self.num_of_atr]):
            self.draw_attribute(y, atr_name=str(e._metas[0]), atr_val=str(
                e._metas[1]), atr_contrib=e._x[0], error=e._x[1])

    def draw_header_footer(self, wp, header_h, unit_pixels, last_y, first_y, marking_len=15):
        """header"""
        max_x = self.max_contrib * self.scale

        atr_label = QGraphicsSimpleTextItem("Name", None)
        val_label = QGraphicsSimpleTextItem("Value", None)
        score_label = QGraphicsSimpleTextItem("Score", None)

        font = score_label.font()
        font.setBold(True)
#.........这里部分代码省略.........
开发者ID:pavlin-policar,项目名称:orange3-prototypes,代码行数:103,代码来源:owexplpredictions.py


注:本文中的AnyQt.QtGui.QPen.setStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。