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


Python QColorDialog.getColor方法代码示例

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


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

示例1: choose_color

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def choose_color(self):
     col = QColorDialog.getColor(self.current_color or Qt.black, self, _('Choose color'))
     if col.isValid():
         self.current_color = col
         self.update_tooltip()
         self.ic.fill(col)
         self.setIcon(QIcon(self.ic))
         self.data[self.name] = self.value
         self.changed.emit()
开发者ID:davidfor,项目名称:calibre,代码行数:11,代码来源:themes.py

示例2: change_cover_grid_color

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def change_cover_grid_color(self):
     col = QColorDialog.getColor(self.cg_bg_widget.bcol,
                           self.gui, _('Choose background color for cover grid'))
     if col.isValid():
         col = tuple(col.getRgb())[:3]
         self.set_cg_color(col)
         self.changed_signal.emit()
         if self.cg_bg_widget.btex:
             if question_dialog(
                 self, _('Remove background image?'),
                 _('There is currently a background image set, so the color'
                   ' you have chosen will not be visible. Remove the background image?')):
                 self.set_cg_texture(None)
开发者ID:GaryMMugford,项目名称:calibre,代码行数:15,代码来源:look_feel.py

示例3: change_color

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def change_color(self, which, reset=False):
     if reset:
         setattr(self, "current_%s_color" % which, None)
     else:
         initial = getattr(self, "current_%s_color" % which)
         if initial:
             initial = QColor(initial)
         else:
             initial = Qt.black if which == "text" else Qt.white
         title = _("Choose text color") if which == "text" else _("Choose background color")
         col = QColorDialog.getColor(initial, self, title, QColorDialog.ShowAlphaChannel)
         if col.isValid():
             name = unicode(col.name())
             setattr(self, "current_%s_color" % which, name)
     self.update_sample_colors()
开发者ID:Cykooz,项目名称:calibre,代码行数:17,代码来源:config.py

示例4: format_text

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def format_text(self, formatting):
     if self.syntax != "html":
         return
     if formatting.startswith("justify_"):
         return self.smarts.set_text_alignment(self, formatting.partition("_")[-1])
     color = "currentColor"
     if formatting in {"color", "background-color"}:
         color = QColorDialog.getColor(
             QColor(Qt.black if formatting == "color" else Qt.white),
             self,
             _("Choose color"),
             QColorDialog.ShowAlphaChannel,
         )
         if not color.isValid():
             return
         r, g, b, a = color.getRgb()
         if a == 255:
             color = "rgb(%d, %d, %d)" % (r, g, b)
         else:
             color = "rgba(%d, %d, %d, %.2g)" % (r, g, b, a / 255)
     prefix, suffix = {
         "bold": ("<b>", "</b>"),
         "italic": ("<i>", "</i>"),
         "underline": ("<u>", "</u>"),
         "strikethrough": ("<strike>", "</strike>"),
         "superscript": ("<sup>", "</sup>"),
         "subscript": ("<sub>", "</sub>"),
         "color": ('<span style="color: %s">' % color, "</span>"),
         "background-color": ('<span style="background-color: %s">' % color, "</span>"),
     }[formatting]
     left, right = self.get_range_inside_tag()
     c = self.textCursor()
     c.setPosition(left)
     c.setPosition(right, c.KeepAnchor)
     prev_text = unicode(c.selectedText()).rstrip("\0")
     c.insertText(prefix + prev_text + suffix)
     if prev_text:
         right = c.position()
         c.setPosition(left)
         c.setPosition(right, c.KeepAnchor)
     else:
         c.setPosition(c.position() - len(suffix))
     self.setTextCursor(c)
开发者ID:timpalpant,项目名称:calibre,代码行数:45,代码来源:text.py

示例5: format_text

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def format_text(self, formatting):
     if self.syntax != 'html':
         return
     if formatting.startswith('justify_'):
         return self.smarts.set_text_alignment(
             self,
             formatting.partition('_')[-1])
     color = 'currentColor'
     if formatting in {'color', 'background-color'}:
         color = QColorDialog.getColor(
             QColor(Qt.black if formatting == 'color' else Qt.white), self,
             _('Choose color'), QColorDialog.ShowAlphaChannel)
         if not color.isValid():
             return
         r, g, b, a = color.getRgb()
         if a == 255:
             color = 'rgb(%d, %d, %d)' % (r, g, b)
         else:
             color = 'rgba(%d, %d, %d, %.2g)' % (r, g, b, a / 255)
     prefix, suffix = {
         'bold': ('<b>', '</b>'),
         'italic': ('<i>', '</i>'),
         'underline': ('<u>', '</u>'),
         'strikethrough': ('<strike>', '</strike>'),
         'superscript': ('<sup>', '</sup>'),
         'subscript': ('<sub>', '</sub>'),
         'color': ('<span style="color: %s">' % color, '</span>'),
         'background-color': ('<span style="background-color: %s">' % color,
                              '</span>'),
     }[formatting]
     left, right = self.get_range_inside_tag()
     c = self.textCursor()
     c.setPosition(left)
     c.setPosition(right, c.KeepAnchor)
     prev_text = unicode(c.selectedText()).rstrip('\0')
     c.insertText(prefix + prev_text + suffix)
     if prev_text:
         right = c.position()
         c.setPosition(left)
         c.setPosition(right, c.KeepAnchor)
     else:
         c.setPosition(c.position() - len(suffix))
     self.setTextCursor(c)
开发者ID:kovidgoyal,项目名称:calibre,代码行数:45,代码来源:text.py

示例6: background_color

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def background_color(self):
     col = QColorDialog.getColor(Qt.white, self,
             _('Choose background color'), QColorDialog.ShowAlphaChannel)
     if col.isValid():
         self.exec_command('hiliteColor', unicode(col.name()))
开发者ID:andy-5,项目名称:calibre,代码行数:7,代码来源:comments_editor.py

示例7: foreground_color

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def foreground_color(self):
     col = QColorDialog.getColor(Qt.black, self,
             _('Choose foreground color'), QColorDialog.ShowAlphaChannel)
     if col.isValid():
         self.exec_command('foreColor', unicode(col.name()))
开发者ID:andy-5,项目名称:calibre,代码行数:7,代码来源:comments_editor.py

示例8: choose_color

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def choose_color(self):
     c = QColorDialog.getColor(self._color, self, _('Choose color'))
     if c.isValid():
         self._color = c
         self.update_display()
开发者ID:GRiker,项目名称:calibre,代码行数:7,代码来源:covers.py

示例9: choose_color

# 需要导入模块: from PyQt5.Qt import QColorDialog [as 别名]
# 或者: from PyQt5.Qt.QColorDialog import getColor [as 别名]
 def choose_color(self):
     col = QColorDialog.getColor(QColor(self._color or Qt.white), self, _('Choose a color'))
     if col.isValid():
         self.color = unicode(col.name())
开发者ID:Aliminator666,项目名称:calibre,代码行数:6,代码来源:widgets2.py


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