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


Python Qt.QColorDialog类代码示例

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


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

示例1: openColorChooserDialog

 def openColorChooserDialog(self):
     """
     Prompts the user to choose a color and then updates colorFrame with
     the selected color.
     """
     qcolor = RGBf_to_QColor(self.color)
     if not self.color in self.standardColorList:
         QColorDialog.setCustomColor(self.customColorCount, qcolor.rgb())
         self.customColorCount += 1
     c = QColorDialog.getColor(qcolor, self)
     if c.isValid():
         self.setColor(QColor_to_RGBf(c))
         self.colorFrame.emit(SIGNAL("editingFinished()"))
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:13,代码来源:PM_ColorChooser.py

示例2: change_cover_grid_color

 def change_cover_grid_color(self):
     col = QColorDialog.getColor(self.cover_grid_color_label.palette().color(QPalette.Window),
                           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()
开发者ID:banksps,项目名称:calibre,代码行数:7,代码来源:look_feel.py

示例3: change_color

 def change_color(self, color_name):
     if not hasattr(self, color_name): return
     color = getattr(self, color_name)
     color = QColorDialog.getColor(color, self.ui)
     setattr(self, color_name, color)
     getattr(self.ui, color_name+"Button").setStyleSheet(
         "background-color:" + color.name())
开发者ID:dodo,项目名称:blain,代码行数:7,代码来源:preference.py

示例4: change_chunk_color

 def change_chunk_color(self):
     """
     Slot method to change the chunk's color.
     """
     color = QColorDialog.getColor(self.chunk_QColor, self)
     
     if color.isValid():
         plt = QtGui.QPalette()      
         plt.setColor(QtGui.QPalette.Active,QtGui.QPalette.Window,color)
         plt.setColor(QtGui.QPalette.Inactive,QtGui.QPalette.Window,color)
         plt.setColor(QtGui.QPalette.Disabled,QtGui.QPalette.Window,color)
         self.chunk_color_frame.setPalette(plt)
         
         self.chunk_QColor = color
         self.chunk.color = QColor_to_RGBf(color)
         self.chunk.setcolor(self.chunk.color)
         if self.chunk.hidden: # A hidden chunk has no glpane attr.
             return            
         #Ninad 070321: 
         #Note:
         #The chunk is NOT unpicked immediately after changing the color via 
         #chunk property dialog, This is intentional. 
         #BTW I don't know why it deselects the chunk  after hitting OK or Cancel!
         #(looks like an old Qt4 transition bug) 
         self.glpane.gl_update()
开发者ID:elfion,项目名称:nanoengineer,代码行数:25,代码来源:ChunkProp.py

示例5: changeGridColor

 def changeGridColor(self):
     """
     Open the stand color chooser dialog to change grid line color
     """
     c = QColorDialog.getColor(QColor(222,148,0), self)
     if c.isValid():
         self.gridColorLabel.setPaletteBackgroundColor(c)
         self.command.setGridLineColor(c)
开发者ID:elfion,项目名称:nanoengineer,代码行数:8,代码来源:BuildCrystal_PropertyManager.py

示例6: choose_color

 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:pgarst,项目名称:calibre,代码行数:9,代码来源:themes.py

示例7: change_grid_color

    def change_grid_color(self):
        '''Slot method to change grid color.'''
        color = QColorDialog.getColor(self.grid_color, self)

        if color.isValid():            
            self.grid_color = color
            self.grid_color_pixmap = get_widget_with_color_palette(
            self.grid_color_pixmap, self.grid_color)
            self.grid_plane.grid_color = QColor_to_RGBf(color)
            self.glpane.gl_update()
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:10,代码来源:GridPlaneProp.py

示例8: change_border_color

    def change_border_color(self):
        '''Slot method change border color.'''
        color = QColorDialog.getColor(self.border_color, self)

        if color.isValid():
            self.border_color = color
            self.border_color_pixmap = get_widget_with_color_palette(
                self.border_color_pixmap,self.border_color)
            self.grid_plane.color = self.grid_plane.normcolor = QColor_to_RGBf(color)
            self.glpane.gl_update()
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:10,代码来源:GridPlaneProp.py

示例9: chooseCustomBackgroundColor

 def chooseCustomBackgroundColor(self):
     """
     Choose a custom background color.
     """
     c = QColorDialog.getColor(RGBf_to_QColor(self.win.glpane.getBackgroundColor()), self)
     if c.isValid():
         self.win.glpane.setBackgroundColor(QColor_to_RGBf(c))
         self.updateCustomColorItemIcon(c)
     else:
         # User cancelled. Need to reset combobox to correct index.
         self._updateBackgroundColorComboBoxIndex()
     return
开发者ID:foulowl,项目名称:nanoengineer,代码行数:12,代码来源:ColorScheme_PropertyManager.py

示例10: change_cover_grid_color

 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:HaraldGustafsson,项目名称:calibre,代码行数:13,代码来源:look_feel.py

示例11: colorchoose

def colorchoose(self, r, g, b):
    """
    #doc -- note that the args r,g,b should be ints, but the retval
    is a 3-tuple of floats. (Sorry, that's how I found it.)
    """
    # r, g, b is the default color displayed in the QColorDialog window.
    from PyQt4.Qt import QColorDialog
    color = QColorDialog.getColor(QColor(r, g, b), self, "choose") #k what does "choose" mean?
    if color.isValid():
        return color.red()/255.0, color.green()/255.0, color.blue()/255.0
    else:
        return r/255.0, g/255.0, b/255.0 # returning None might be more useful, since it lets callers "not change anything"
    pass
开发者ID:foulowl,项目名称:nanoengineer,代码行数:13,代码来源:widget_helpers.py

示例12: change_color

 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:Hainish,项目名称:calibre,代码行数:17,代码来源:config.py

示例13: colorpref_edit_dialog

def colorpref_edit_dialog( parent, prefs_key, caption = "choose"): #bruce 050805; revised 070425 in Qt4 branch
    #bruce 050805: heavily modified this from some slot methods in UserPrefs.py.
    # Note that the new code for this knows the prefs key and that it's a color,
    # and nothing else that those old slot methods needed to know!
    # It no longer needs to know about the color swatch (if any) that shows this color in the UI,
    # or what/how to update anything when the color is changed,
    # or where the color is stored besides in env.prefs.
    # That knowledge now resides with the code that defines it, or in central places.
    
    old_color = RGBf_to_QColor( env.prefs[prefs_key] )
    c = QColorDialog.getColor(old_color, parent) # In Qt3 this also had a caption argument
    if c.isValid():
        new_color = (c.red()/255.0, c.green()/255.0, c.blue()/255.0)
        env.prefs[prefs_key] = new_color
            # this is change tracked, which permits the UI's color swatch
            # (as well as the glpane itself, or whatever else uses this prefs color)
            # to notice this and update its color
    return
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:18,代码来源:prefs_widgets.py

示例14: format_text

 def format_text(self, formatting):
     if self.syntax != "html":
         return
     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:paranoidsp,项目名称:calibre,代码行数:41,代码来源:text.py

示例15: format_text

 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:piewsook,项目名称:calibre,代码行数:38,代码来源:text.py


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