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


Python QColor.setAlphaF方法代码示例

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


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

示例1: get_color

# 需要导入模块: from spyderlib.qt.QtGui import QColor [as 别名]
# 或者: from spyderlib.qt.QtGui.QColor import setAlphaF [as 别名]
def get_color(value, alpha):
    """Return color depending on value type"""
    color = QColor()
    for typ in COLORS:
        if isinstance(value, typ):
            color = QColor(COLORS[typ])
    color.setAlphaF(alpha)
    return color
开发者ID:gyenney,项目名称:Tools,代码行数:10,代码来源:importwizard.py

示例2: data

# 需要导入模块: from spyderlib.qt.QtGui import QColor [as 别名]
# 或者: from spyderlib.qt.QtGui.QColor import setAlphaF [as 别名]
 def data(self, index, role=Qt.DisplayRole):
     """Return data at table index"""
     if not index.isValid():
         return to_qvariant()
     dep = self.dependencies[index.row()]
     if role == Qt.DisplayRole:
         if index.column() == 0:
             value = self.get_value(index)
             return to_qvariant(value)
         else:
             value = self.get_value(index)
             return to_qvariant(value)
     elif role == Qt.TextAlignmentRole:
         return to_qvariant(int(Qt.AlignLeft|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole:
         from spyderlib.dependencies import Dependency
         status = dep.get_status()
         if status == Dependency.NOK:
             color = QColor(Qt.red)
             color.setAlphaF(.25)
             return to_qvariant(color)
开发者ID:rthouvenin,项目名称:spyder,代码行数:23,代码来源:dependencies.py

示例3: get_bgcolor

# 需要导入模块: from spyderlib.qt.QtGui import QColor [as 别名]
# 或者: from spyderlib.qt.QtGui.QColor import setAlphaF [as 别名]
 def get_bgcolor(self, index):
     """Background color depending on value"""
     column = index.column()
     if column == 0:
         color = QColor(Qt.lightGray)
         color.setAlphaF(.8)
         return color
     if not self.bgcolor_enabled:
         return
     value = self.get_value(index.row(), column-1)
     if isinstance(value, _sup_com):
         color_func = abs
     else:
         color_func = float
     if isinstance(value, _sup_nr+_sup_com) and self.bgcolor_enabled:
         vmax, vmin = self.return_max(self.max_min_col, column-1)
         hue = self.hue0 + self.dhue*(vmax-color_func(value)) / (vmax-vmin)
         hue = float(abs(hue))
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
     elif is_text_string(value):
         color = QColor(Qt.lightGray)
         color.setAlphaF(.05)
     else:
         color = QColor(Qt.lightGray)
         color.setAlphaF(.3)
     return color
开发者ID:gyenney,项目名称:Tools,代码行数:28,代码来源:dataframeeditor.py

示例4: populate_tree

# 需要导入模块: from spyderlib.qt.QtGui import QColor [as 别名]
# 或者: from spyderlib.qt.QtGui.QColor import setAlphaF [as 别名]
    def populate_tree(self):
        """Create each item (and associated data) in the tree"""
        if not self.stats:
            warn_item = QTreeWidgetItem(self)
            warn_item.setData(
                0, Qt.DisplayRole,
                _('No timings to display. '
                  'Did you forget to add @profile decorators ?')
                .format(url=WEBSITE_URL))
            warn_item.setFirstColumnSpanned(True)
            warn_item.setTextAlignment(0, Qt.AlignCenter)
            font = warn_item.font(0)
            font.setStyle(QFont.StyleItalic)
            warn_item.setFont(0, font)
            return

        try:
            monospace_font = self.window().editor.get_plugin_font()
        except AttributeError:  # If run standalone for testing
            monospace_font = QFont("Courier New")
            monospace_font.setPointSize(10)

        for func_info, func_data in self.stats.items():
            # Function name and position
            filename, start_line_no, func_name = func_info
            func_stats, func_peak_usage = func_data
            func_item = QTreeWidgetItem(self)
            func_item.setData(
                0, Qt.DisplayRole,
                _('{func_name} (peak {peak_usage:.3f} MiB) in file "{filename}", '
                  'line {line_no}').format(
                    filename=filename,
                    line_no=start_line_no,
                    func_name=func_name,
                    peak_usage=func_peak_usage))
            func_item.setFirstColumnSpanned(True)
            func_item.setData(COL_POS, Qt.UserRole,
                              (osp.normpath(filename), start_line_no))

            # For sorting by time
            func_item.setData(COL_USAGE, Qt.DisplayRole, func_peak_usage)
            func_item.setData(COL_INCREMENT, Qt.DisplayRole,
                              func_peak_usage)

            if self.parent().use_colors:
                # Choose deteministic unique color for the function
                md5 = hashlib.md5((filename + func_name).encode("utf8")).hexdigest()
                hue = (int(md5[:2], 16) - 68) % 360  # avoid blue (unreadable)
                func_color = QColor.fromHsv(hue, 200, 255)
            else:
                # Red color only
                func_color = QColor.fromRgb(255, 0, 0)

            # get max increment
            max_increment = 0
            for line_info in func_stats:
                (line_no, code_line, usage, increment) = line_info
                if increment is not None:
                    max_increment = max(max_increment, increment)

            # Lines of code
            for line_info in func_stats:
                line_item = QTreeWidgetItem(func_item)
                (line_no, code_line, usage, increment) = line_info
                self.fill_item(
                    line_item, filename, line_no, code_line,
                    usage, increment)

                # Color background
                if increment is not None:
                    alpha = increment / max_increment if max_increment != 0 else 0
                    color = QColor(func_color)
                    color.setAlphaF(alpha)  # Returns None
                    color = QBrush(color)
                    for col in range(self.columnCount()):
                        line_item.setBackground(col, color)
                else:

                    for col in range(self.columnCount()):
                        line_item.setForeground(col, CODE_NOT_RUN_COLOR)

                # Monospace font for code
                line_item.setFont(COL_LINE, monospace_font)
开发者ID:Nodd,项目名称:spyder_line_profiler,代码行数:85,代码来源:memoryprofilergui.py


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