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()"))
Example #2
0
 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()"))
Example #3
0
 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()
Example #4
0
 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()
Example #5
0
 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())
Example #6
0
 def func():
     from PyQt4.Qt import QColorDialog
     color = QColorDialog.getColor( qcolor_from_anything(curval), dialog_parent) 
     if color.isValid():
         newval = color.red()/255.0, color.green()/255.0, color.blue()/255.0
         newval_receiver_func(newval)
     return
Example #7
0
    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()
Example #8
0
 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()
 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)
Example #10
0
 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)
Example #11
0
 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()
Example #12
0
 def func():
     from PyQt4.Qt import QColorDialog
     color = QColorDialog.getColor(qcolor_from_anything(curval),
                                   dialog_parent)
     if color.isValid():
         newval = color.red() / 255.0, color.green() / 255.0, color.blue(
         ) / 255.0
         newval_receiver_func(newval)
     return
Example #13
0
    def change_jig_color(self):
        """Slot method to change the jig's color."""
        color = QColorDialog.getColor(self.jig_QColor, self)

        if color.isValid():
            self.jig_QColor = color
            self.jig_color_pixmap = get_widget_with_color_palette(self.jig_color_pixmap, self.jig_QColor)
            self.jig.color = self.jig.normcolor = QColor_to_RGBf(color)
            self.glpane.gl_update()
Example #14
0
 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()
Example #15
0
    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()
Example #16
0
    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()
Example #17
0
    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()
Example #18
0
    def change_jig_color(self):
        '''Slot method to change the jig's color.'''
        color = QColorDialog.getColor(self.jig_QColor, self)

        if color.isValid():
            self.jig_QColor = color
            self.jig_color_pixmap = get_widget_with_color_palette(
                self.jig_color_pixmap, self.jig_QColor)
            self.jig.color = self.jig.normcolor = QColor_to_RGBf(color)
            self.glpane.gl_update()
Example #19
0
    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()
 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
Example #21
0
    def change_fill_color(self):
        """
        Slot method to change fill color.
        """
        color = QColorDialog.getColor(self.fill_QColor, self)

        if color.isValid():            
            self.fill_QColor = color
            self.fill_color_pixmap = get_widget_with_color_palette(
                self.fill_color_pixmap, self.fill_QColor)
            
            self.jig.fill_color = QColor_to_RGBf(color)
            self.glpane.gl_update()
Example #22
0
 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)
Example #23
0
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
Example #24
0
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
Example #25
0
 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()
Example #26
0
 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()
Example #27
0
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
Example #28
0
 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)
Example #29
0
 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)
Example #30
0
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
Example #31
0
 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)
Example #32
0
 def __init__(self, parent=None):
     QColorDialog.__init__(self, parent)
 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()))
 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()))
Example #35
0
 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())
Example #36
0
 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())
Example #37
0
    def dispObjectColor(self, initialColor = None):
        """
        Sets the color of the selected chunks and/or jigs to a color the user 
        chooses.

        @param initialColor: the initial color to display in the color chooser
                             dialog, or None or missing to use the default (white).
                             Not used if only one chunk or one jig is selected
                             (in those cases the object's current color is used).
        @type  initialColor: QColor

        @note: Need better method name (i.e. setObjectColor()).
        """        
        if initialColor is None:
            initialColor = Qt.white
        else:
            assert isinstance(initialColor, QColor)
        
        _cmd = greenmsg("Change Color: ")

        from operations.ops_select import objectSelected, ATOMS, CHUNKS, JIGS
        if not objectSelected(self.assy, objectFlags = CHUNKS | JIGS):
            if objectSelected(self.assy, objectFlags = ATOMS):
                _msg = redmsg("Cannot change color of individual atoms.")
            else:
                _msg = redmsg("Nothing selected.")
            env.history.message(_cmd + _msg)
            return

        _numSelectedObjects = self.assy.getNumberOfSelectedChunks() \
                            + self.assy.getNumberOfSelectedJigs()

        if _numSelectedObjects == 1 and self.assy.getNumberOfSelectedChunks() == 1:
            # If only one object is selected, and it's a chunk, 
            # assign initialColor its color.
            _selectedChunkColor = self.assy.selmols[0].color
            if _selectedChunkColor:
                from widgets.widget_helpers import RGBf_to_QColor
                initialColor = RGBf_to_QColor(_selectedChunkColor)

        elif _numSelectedObjects == 1 and self.assy.getNumberOfSelectedJigs() == 1:
            # If only one object is selected, and it's a jig, 
            # assign initialColor its color.
            _selectedJig = self.assy.getSelectedJigs()
            _selectedJigColor = _selectedJig[0].normcolor
            if _selectedJigColor:
                from widgets.widget_helpers import RGBf_to_QColor
                initialColor = RGBf_to_QColor(_selectedJigColor)

        _c = QColorDialog.getColor(initialColor, self)
        if _c.isValid():
            from widgets.widget_helpers import QColor_to_RGBf
            _newColor = QColor_to_RGBf(_c)
            list = []
            for ob in self.assy.selmols:
                ob.setcolor(_newColor)
                list.append(ob)

            for ob in self.assy.getSelectedJigs():
                ob.color = _newColor # Need jig.setColor() method! --mark
                ob.normcolor =  _newColor
                list.append(ob)

            # Ninad 070321: Since the chunk is selected as a colored selection, 
            # it should be unpicked after changing its color. 
            # The user has most likely selected the chunk to change its color 
            # and won't like it still shown 'green'(the selection color) 
            # even after changing the color. so deselect it. 	
            # The chunk is NOT unpicked IF the color is changed via chunk 
            # property dialog. see ChunkProp.change_chunk_color for details.
            # This is intentional.

            for ob in list: 		
                ob.unpick()

            self.win_update()
Example #38
0
 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()))
Example #39
0
 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()))