• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python QtGui.QColor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_bgcolor

 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,代码行数:26,代码来源:dataframeeditor.py


示例2: get_color

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,代码行数:8,代码来源:importwizard.py


示例3: data

 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return to_qvariant()
     value = self.get_value(index)
     if is_binary_string(value):
         try:
             value = to_text_string(value, 'utf8')
         except:
             pass
     if role == Qt.DisplayRole:
         if value is np.ma.masked:
             return ''
         else:
             return to_qvariant(self._format % value)
     elif role == Qt.TextAlignmentRole:
         return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole and self.bgcolor_enabled \
       and value is not np.ma.masked:
         hue = self.hue0+\
               self.dhue*(self.vmax-self.color_func(value)) \
               /(self.vmax-self.vmin)
         hue = float(np.abs(hue))
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
         return to_qvariant(color)
     elif role == Qt.FontRole:
         return to_qvariant(get_font('arrayeditor'))
     return to_qvariant()
开发者ID:wellsoftware,项目名称:spyder,代码行数:28,代码来源:arrayeditor.py


示例4: ColorButton

class ColorButton(QPushButton):
    """
    Color choosing push button
    """
    __pyqtSignals__ = ("colorChanged(QColor)",)
    
    def __init__(self, parent=None):
        QPushButton.__init__(self, parent)
        self.setFixedSize(20, 20)
        self.setIconSize(QSize(12, 12))
        self.connect(self, SIGNAL("clicked()"), self.choose_color)
        self._color = QColor()
    
    def choose_color(self):
        rgba, valid = QColorDialog.getRgba(self._color.rgba(),
                                           self.parentWidget())
        if valid:
            color = QColor.fromRgba(rgba)
            self.set_color(color)
    
    def get_color(self):
        return self._color
    
    @Slot(QColor)
    def set_color(self, color):
        if color != self._color:
            self._color = color
            self.emit(SIGNAL("colorChanged(QColor)"), self._color)
            pixmap = QPixmap(self.iconSize())
            pixmap.fill(color)
            self.setIcon(QIcon(pixmap))
    
    color = Property("QColor", get_color, set_color)
开发者ID:jromang,项目名称:retina-old,代码行数:33,代码来源:formlayout.py


示例5: text_to_qcolor

def text_to_qcolor(text):
    """
    Create a QColor from specified string
    Avoid warning from Qt when an invalid QColor is instantiated
    """
    color = QColor()
    text = str(text)
    if not isinstance(text, (unicode, str)):
        return color
    if text.startswith('#') and len(text)==7:
        correct = '#0123456789abcdef'
        for char in text:
            if char.lower() not in correct:
                return color
    elif text not in list(QColor.colorNames()):
        return color
    color.setNamedColor(text)
    return color
开发者ID:jromang,项目名称:retina-old,代码行数:18,代码来源:colors.py


示例6: data

 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,代码行数:21,代码来源:dependencies.py


示例7: __init__

    def __init__(self, parent, opacity, duration, easing_curve):
        super(FadingTipBox, self).__init__(parent, opacity, duration,
                                           easing_curve)
        self.holder = self.anim  # needed for qt to work
        self.parent = parent

        self.frames = None
        self.color_top = QColor.fromRgb(230, 230, 230)
        self.color_back = QColor.fromRgb(255, 255, 255)
        self.offset_shadow = 0
        self.fixed_width = 300

        self.key_pressed = None

        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint |
                            Qt.WindowStaysOnTopHint)
        self.setModal(False)

        # Widgets
        self.button_home = QPushButton("<<")
        self.button_close = QPushButton("X")
        self.button_previous = QPushButton(" < ")
        self.button_end = QPushButton(">>")
        self.button_next = QPushButton(" > ")
        self.button_run = QPushButton(_('Run code'))
        self.button_disable = None
        self.button_current = QToolButton()
        self.label_image = QLabel()

        self.label_title = QLabel()
        self.combo_title = QComboBox()
        self.label_current = QLabel()
        self.label_content = QLabel()

        self.label_content.setMinimumWidth(self.fixed_width)
        self.label_content.setMaximumWidth(self.fixed_width)

        self.label_current.setAlignment(Qt.AlignCenter)

        self.label_content.setWordWrap(True)

        self.widgets = [self.label_content, self.label_title,
                        self.label_current, self.combo_title,
                        self.button_close, self.button_run, self.button_next,
                        self.button_previous, self.button_end,
                        self.button_home, self.button_current]

        arrow = get_image_path('hide.png')

        self.stylesheet = '''QPushButton {
                             background-color: rgbs(200,200,200,100%);
                             color: rgbs(0,0,0,100%);
                             border-style: outset;
                             border-width: 1px;
                             border-radius: 3px;
                             border-color: rgbs(100,100,100,100%);
                             padding: 2px;
                             }

                             QPushButton:hover {
                             background-color: rgbs(150, 150, 150, 100%);
                             }

                             QPushButton:disabled {
                             background-color: rgbs(230,230,230,100%);
                             color: rgbs(200,200,200,100%);
                             border-color: rgbs(200,200,200,100%);
                             }

                             QComboBox {
                             padding-left: 5px;
                             background-color: rgbs(230,230,230,100%);
                             border-width: 0px;
                             border-radius: 0px;
                             min-height:20px;
                             max-height:20px;
                             }

                             QComboBox::drop-down  {
                             subcontrol-origin: padding;
                             subcontrol-position: top left;
                             border-width: 0px;
                             }
                             
                             QComboBox::down-arrow {
                             image: url(''' + arrow + ''');
                             }
                             
                             '''
        # Windows fix, slashes should be always in unix-style
        self.stylesheet = self.stylesheet.replace('\\', '/')

        for widget in self.widgets:
            widget.setFocusPolicy(Qt.NoFocus)
            widget.setStyleSheet(self.stylesheet)

        layout_top = QHBoxLayout()
        layout_top.addWidget(self.combo_title)
        layout_top.addStretch()
#.........这里部分代码省略.........
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:101,代码来源:tour.py


示例8: populate_tree

    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,代码行数:83,代码来源:memoryprofilergui.py


示例9: get_translation

try:
    from spyderlib.py3compat import to_text_string, getcwd
except ImportError:
    # python2
    to_text_string = unicode
    getcwd = os.getcwdu
_ = get_translation("p_memoryprofiler", dirname="spyderplugins")


COL_NO = 0
COL_USAGE = 1
COL_INCREMENT = 2
COL_LINE = 3
COL_POS = 0  # Position is not displayed but set as Qt.UserRole

CODE_NOT_RUN_COLOR = QBrush(QColor.fromRgb(128, 128, 128, 200))

WEBSITE_URL = 'https://pypi.python.org/pypi/memory_profiler/'


def is_memoryprofiler_installed():
    """Checks if the library for memory_profiler is installed
    """
    return programs.is_module_installed('memory_profiler')


class MemoryProfilerWidget(QWidget):
    """
    Memory profiler widget
    """
    DATAPATH = get_conf_path('memoryprofiler.results')
开发者ID:Nodd,项目名称:spyder_line_profiler,代码行数:31,代码来源:memoryprofilergui.py


示例10: choose_color

 def choose_color(self):
     rgba, valid = QColorDialog.getRgba(self._color.rgba(),
                                        self.parentWidget())
     if valid:
         color = QColor.fromRgba(rgba)
         self.set_color(color)
开发者ID:jromang,项目名称:retina-old,代码行数:6,代码来源:formlayout.py


示例11: __init__

 def __init__(self, parent=None):
     QPushButton.__init__(self, parent)
     self.setFixedSize(20, 20)
     self.setIconSize(QSize(12, 12))
     self.connect(self, SIGNAL("clicked()"), self.choose_color)
     self._color = QColor()
开发者ID:jromang,项目名称:retina-old,代码行数:6,代码来源:formlayout.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python QtGui.QComboBox类代码示例发布时间:2022-05-27
下一篇:
Python QtGui.QCheckBox类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap