def setColor(self): colorDialog = QColorDialog() if self.tag: color = self.tag.color() qcolor = colorDialog.getColor(QColor(color.r, color.g, color.b)) else: qcolor = colorDialog.getColor() if qcolor.isValid(): self.setEditColor(qcolor) self.tagColor = (qcolor.red(), qcolor.green(), qcolor.blue())
def selectColor(self): self.setChecked(True) color = QColorDialog.getColor(self._color) self.setChecked(False) if color != self._color: self.setColor(color) self.emit(SIGNAL("colorChanged()"))
def showColorDialog(self, frame): col = QColorDialog.getColor() if col.isValid(): frame.setStyleSheet("QWidget { background-color: %s }" % col.name()) self.DATA['colors'][unicode(frame.objectName())] = unicode( col.name())
def slotBaseColor(self): """Slot function to update the basecolor if the color has been changed """ self.ColorScheme.baseColor = QColorDialog.getColor( self.ColorScheme.baseColor, self, "ColorDialog") self.ColorScheme.generateScheme() self.setBackgroundColor(self.chipBaseColor, self.ColorScheme.baseColor)
def _pick_color(self, lineedit, btn): """Pick a color name using lineedit and button data.""" color = QColorDialog.getColor(QColor(lineedit.text()), self, translations.TR_EDITOR_SCHEME_PICK_COLOR) if color.isValid(): lineedit.setText(str(color.name())) self.apply_button_style(btn, color.name())
def openColorDialog(self, initcolor): colordialog = QColorDialog() selectedcolor = colordialog.getColor(initcolor, None, 'Please select a color') if selectedcolor.isValid(): return selectedcolor else: return initcolor
def action(self): qt_color_old = QColor(self.value) qt_color = QColorDialog.getColor(qt_color_old) if qt_color.isValid(): self.value = qt_color.name() self.app.refresh()
def updateColor(self): """ Update the color on the sampleModel modify to fit to the actual view """ if not self.view.sampleTableView.selectedIndexes():#not self.acTree.selectedIndexes(): return idx = self.view.sampleTableView.selectedIndexes()[0] sample = self.model.sample(idx.data().toString(), fullNameEntry=False) if sample is None: self.view.showErrorMessage('Error', 'Please choose only one file...') return color = QColorDialog.getColor() if not color.isValid(): return sample.color=color.getRgbF()[:-1] #make the gradient color here to color =QColor.fromRgbF(*(sample.color+(1.,))) colorr=QColor.fromRgbF(*(sample.color+(.5,))) gradient=QLinearGradient(-100, -100, 100, 100) gradient.setColorAt(0.7, colorr) gradient.setColorAt(1, color) #for m in (self.view.sampleModel, self.view.spectraModel, self.view.peakModel, # self.view.clusterModel):#self.view.chromaModel, for i in xrange(self.view.sampleModel.rowCount()): item=self.view.sampleModel.item(i,0) if item.text()== sample.shortName(): item.setBackground(QBrush(gradient))
def edit_layer_color(layer): """ Interactively edit a layer's color """ dialog = QColorDialog() initial = mpl_to_qt4_color(layer.style.color) color = dialog.getColor(initial=initial) if color.isValid(): layer.style.color = qt4_to_mpl_color(color)
def mouseReleaseEvent(self, QMouseEvent): color = QColorDialog.getColor(self._color, self, "Select color", QColorDialog.ShowAlphaChannel) if color.isValid(): self._color = color self.update() self.colorChanged.emit(self._color)
def getLabelColor(self): color = QColorDialog.getColor(QColor(self.label_color.text())) if not color.isValid(): return if not color is None: self.label_color.setText(color.name()) self.label_color_button.setStyleSheet("background:"+unicode(color.name()))
def changeHabColor(self): currRow = self.habTableWidget.currentRow() color_item = QTableWidgetItem() new_qcolor = QColorDialog.getColor(parent=self) if new_qcolor.isValid(): color_item.setBackgroundColor( new_qcolor ) color_item.setText( new_qcolor.name() ) self.habTableWidget.setItem(currRow,2,color_item)
def pickColor(self): """ Prompts the user to select a color for this button. """ color = QColorDialog.getColor(self.color(), self) if (color.isValid()): self.setColor(color)
| |>>> # create connections |>>> def printColor(clr): print clr.red(), clr.green(), clr.blue() |>>> btn.colorChanged.connect(printColor) | |>>> # prompt the user to select a color for that button |>>> btn.pickColor() """
def updateColor(self): newcolor = QColorDialog.getColor(QColor.fromRgb(int("%d" % int(self.value, 16))), None )# Non supporté sous Jaunty ?? if newcolor.isValid(): self.value = str("%x" % newcolor.rgb())[2:] self.color.fill(QColor.fromRgb(int("%d" % int(self.value, 16)))) self.boutton.setIcon(QIcon(self.color)) self.line.setText(self.value) EkdConfig.set(self.section, self.id, self.value)
def edit_layer_color(layer): """ Interactively edit a layer's color """ initial = mpl_to_qt4_color(layer.style.color, alpha=layer.style.alpha) color = QColorDialog.getColor(initial, None, "Change layer color", options=QColorDialog.ShowAlphaChannel) if color.isValid(): layer.style.color = qt4_to_mpl_color(color) layer.style.alpha = color.alpha() / 256.
def color_picker(self, a): self.cp = QColorDialog.getColor() if a == 0: self.colorPrimaryLbl.setText(self.cp.name()) self.colorPrimaryLbl.setStyleSheet("background-color:"+self.cp.name() +"") elif a == 1: self.colorSecondaryLbl.setText(self.cp.name()) self.colorSecondaryLbl.setStyleSheet("background-color:"+self.cp.name() +"")
def _onClicked(self): """Button has been clicked. Show dialog and update color """ color = QColorDialog.getColor(self._color, self.window(), tr("Choose a color"), QColorDialog.ShowAlphaChannel) if color.isValid(): self.setColor(color)
def change_point_color(self, color=None): #blue 4279259391 if color == None: color = QColorDialog.getColor(QColor(4279259391), None, 'Point color', QColorDialog.ShowAlphaChannel) if color.isValid(): self.curve.setSymbolBrush(color)
def change_line_color(self, color=None): #yellow 4294967040 if color == None: color = QColorDialog.getColor(QColor(4294967040), None, 'Line color', QColorDialog.ShowAlphaChannel) if color.isValid(): self.curve.setPen(color)
def edit_cell(self, row, column): if column == 1: color_item = self.ui.compareList.item(row, column) color = QColor(color_item.text()) result = QColorDialog.getColor(initial=color, parent=self) if result.isValid(): color_item.setText(result.name()) color_item.setBackgroundColor(result)
def setColor(self): colorDialog = QColorDialog(self) colorDialog.setOption(QColorDialog.ShowAlphaChannel) self.color = colorDialog.getColor() self.color = self.color.name() self.label.setText(self.text+":"+self.color) self.setBtnColor() self.emit(SIGNAL("colorChange"),str(self.text),str(self.color))
def changeHabColor(self): currRow = self.habTableWidget.currentRow() color_item = QTableWidgetItem() new_qcolor = QColorDialog.getColor(parent=self) if new_qcolor.isValid(): color_item.setBackgroundColor(new_qcolor) color_item.setText(new_qcolor.name()) self.habTableWidget.setItem(currRow, 2, color_item)
def _pick_color(self, lineedit, btn): """Pick a color name using lineedit and button data.""" color = QColorDialog.getColor( QColor(lineedit.text()), self, translations.TR_EDITOR_SCHEME_PICK_COLOR) if color.isValid(): lineedit.setText(str(color.name())) self.apply_button_style(btn, color.name())
def createColorDialog(self): """ Create a dialog box to select a color. """ newColor = QColorDialog.getColor(self.getQColor(), self._app.ui.workspace, "Select Color", QColorDialog.ShowAlphaChannel) if newColor.isValid(): self.setColor(newColor)
def chooseColor(self, i): if not i < len(self.buttons): return initial = self.buttons[i][1] c = QColorDialog.getColor(initial,self) if initial == c: return pal = self.buttons[i][0].palette() pal.setBrush( QPalette.Button, QColor(c.red(),c.green(),c.blue())) self.buttons[i][0].setPalette(pal) self.buttons[i][1] = c
def setColor(self): colorDialog = QColorDialog(self) colorDialog.setOption(QColorDialog.ShowAlphaChannel) #list = QColor().colorNames() #for i in list: # print(i) color = colorDialog.getColor() self.lab3.setText("Background: "+color.name()) self.parent.setBackgroundColor(color)
def colordialog(self): col = QColorDialog.getColor() button = self.sender() # 获取信号来源 if col.isValid(): button.setStyleSheet('QWidget{background-color:%s}' % col.name()) for b in self.color_btn_list: if button is b: bindex = self.color_btn_list.index(b) self.setting_list[bindex][0] = col
def editTab(self, index): ' handle the editor ' rect = self.tabRect(index) self.setTabTextColor(index, QColorDialog.getColor()) self._editor.setFixedSize(rect.size()) self._editor.move(self.parent().mapToGlobal(rect.topLeft())) self._editor.setText(self.tabText(index)) if not self._editor.isVisible(): self._editor.show()
def __changeColor(self): color = QColorDialog.getColor( QColor.fromRgb(*self.game.clientPlayer.color), self, "Choose your color", ) if color.isValid(): color = color.getRgb() self.colorChanged.emit(list(color[:-1]))
def change_color(self): """ Fire up a QColorDialog to let the user change the color of the lines marking a pattern repeat box. """ color = QColorDialog.getColor(self.color, None, "Select Line Color") self.color = color self.set_button_color()
def customized_color_button_pressed(self): """ Deal with user requests to customize colors. """ oldColor = self._synchronizer.get_active_widget().color color = QColorDialog.getColor(oldColor, None, "Select Custom Color") if color.isValid(): self._synchronizer.change_active_color(color)
def on_push(self): """ When a subset color button is pushed, update the color """ source = self.sender() for key in self.subset_widgets: button = self.subset_widgets[key]['widget'] if button == source: dialog = QColorDialog() initial = mpl_to_qt4_color(key.style.color) color = dialog.getColor(initial = initial) key.style.color = qt4_to_mpl_color(color)
def selectLabelColor(self, label): """Display a color picker allowing the user to change the color of a QLabel, initialized with the current color of the label. If the color picked was valid and the user clicked ok, the color will change """ color = QColorDialog.getColor(get_label_bg_color(label), self) if color.isValid(): set_label_bg_color(label, color)
def pickTextColor(self): """ Prompts the user to select a text color. """ clr = QColorDialog.getColor(self.textColor(), self.window(), 'Pick Text Color') if clr.isValid(): self.setTextColor(clr)
def colorChanged(self, ok): color = QColorDialog.getColor(QColor(self.fragment.background_color)) # user cancelled if not color.isValid(): return # remove the alpha channel self.background_color = color.rgb() & 0x00ffffff self.ui.color.setStyleSheet('background-color: rgb(%d, %d, %d)' % (color.red(), color.green(), color.blue()))
def _itemClicked(self, item, column): if item.option.typeName != QtGui.QColor: return color = QColorDialog.getColor(item.getRawData(), self.parent(), "色選択:"+item.option.displayName, QColorDialog.ColorDialogOptions( QColorDialog.ShowAlphaChannel)) #color = QtGui.QColorDialog.getColor(item.getRawData()) if color.isValid(): item.setRawData(color)
def changeFeatureColour(self, mapfeatureitem): colourdialog = QColorDialog() r, g, b = mapfeatureitem.colour qitemcolour = QColor() qitemcolour.setRgb(r, g, b) r, g, b, a = colourdialog.getColor(initial=qitemcolour).getRgb() mapfeatureitem.visible = not mapfeatureitem.visible self.ui.qimageviewer.changeMapFeatureColour(idstring = mapfeatureitem.idstring, colour = [r, g, b]) mapfeatureitem.colour = [r, g, b] mapfeatureitem.updateText()
def ts_change_color(): """ Open color picker and set chosen color to text (in content) """ global ts_color qcolor_old = QColor(ts_color) qcolor = QColorDialog.getColor(qcolor_old) if qcolor.isValid(): ts_color = qcolor.name() execute_js("color = '" + ts_color + "'") ts_refresh()
def change_row_highlight_color(self): """ Fire up a QColorDialog to change the color for hightlighting odd rows. """ color = self.settings.highlightRowsColor.value newColor = QColorDialog.getColor(QColor(color), None, "Select color for row highlighting") self.settings.highlightRowsColor.value = newColor.name() self._update_highlight_button_color() self.emit(SIGNAL("redraw_highlighted_rows"))
def selectColor(self): item = self.table.currentItem() color = item and QColor(item.background()) or self.table.palette().base().color() color = QColorDialog.getColor(color, self) if not color.isValid(): return selected = self.table.selectedItems() if not selected: return for i in selected: i and i.setBackground(color) self.updateColor(self.table.currentItem())
def changeColor(getr, setr, parent): """ Allow the user to change a color with a QColorDialog. @param getr callable that returns current color @param setr callable to set selected color if dialog is accepted @param parent ancestor of dialog @return new color if dialog is accepted, otherwise None """ oldcolor = QColor(getr()) newcolor = QColorDialog.getColor(oldcolor, parent) if newcolor.isValid(): setr(newcolor) return newcolor
def changeColor(widget): """ Launch the color dialog box in RGBA mode and update the window color of the widget. :returns: True if the color was changed :returntype: `bool` """ c = widget.palette().color(QPalette.Window) ncc = QColorDialog.getColor(c, widget, "Change color", QColorDialog.ShowAlphaChannel) if ncc.isValid(): setColor(widget, ncc) return True return False
def on_color(self): obj = self.out_data['point_properties'] rgb_color_ints = obj.color msg = 'Points' col = QColorDialog.getColor(QColor(*rgb_color_ints), self, "Choose a %s color" % msg) if col.isValid(): color = col.getRgbF()[:3] obj.color = color #print('new_color =', color) self.color_edit.setStyleSheet( "QPushButton {" "background-color: rgb(%s, %s, %s);" % tuple(obj.color) + #"border:1px solid rgb(255, 170, 255); " "}")
def on_color(self): rgb_color_ints = self.int_color col = QColorDialog.getColor(QtGui.QColor(*rgb_color_ints), self, "Choose a label color") if col.isValid(): float_color = col.getRgbF()[:3] # floats self.int_color = [int(colori * 255) for colori in float_color] self.float_color = float_color assert isinstance(self.float_color[0], float), self.float_color assert isinstance(self.int_color[0], int), self.int_color self.color_edit.setStyleSheet("QPushButton {" "background-color: rgb(%s, %s, %s);" % tuple(self.int_color) + #"border:1px solid rgb(255, 170, 255); " "}") self.on_apply(force=True)
def on_color(self, color_edit, rgb_color_ints, title): """pops a color dialog""" col = QColorDialog.getColor(QtGui.QColor(*rgb_color_ints), self, title) if not col.isValid(): return False, rgb_color_ints, None color_float = col.getRgbF()[:3] # floats color_int = [int(colori * 255) for colori in color_float] assert isinstance(color_float[0], float), color_float assert isinstance(color_int[0], int), color_int color_edit.setStyleSheet( "QPushButton {" "background-color: rgb(%s, %s, %s);" % tuple(color_int) + #"border:1px solid rgb(255, 170, 255); " "}") return True, color_int, color_float
def on_color(self): """called when the user clicks on the color box""" name = self.active_key obj = self.out_data[name] rgb_color_ints = obj.color msg = name col = QColorDialog.getColor(QtGui.QColor(*rgb_color_ints), self, "Choose a %s color" % msg) if col.isValid(): color_float = col.getRgbF()[:3] obj.color = color_float color_int = [int(colori * 255) for colori in color_float] self.color_edit.setStyleSheet( "QPushButton {" "background-color: rgb(%s, %s, %s);" % tuple(color_int) + #"border:1px solid rgb(255, 170, 255); " "}") self.on_apply(force=self.force)
def layerSymbology(self): """ Change the features color of a vector layer """ legendLayer = self.currentItem() if legendLayer.isVect == True: geom = legendLayer.canvasLayer.layer().geometryType( ) # QGis Geometry for i in self.layers: if i.layer().id() == legendLayer.layerId: color = QColorDialog.getColor( i.layer().rendererV2().symbols()[0].color(), self.pyQGisApp) break if color.isValid(): pm = QPixmap() iconChild = QIcon() legendLayer.canvasLayer.layer().rendererV2().symbols( )[0].setColor(color) self.canvas.refresh()
def editColor( self, item, index ): """ Prompts the user to pick a new color for the inputed item/column. :param item | <XColorTreeWidgetItem> index | <int> """ if ( not index ): return newcolor = QColorDialog.getColor(item.colorAt(index-1), self) if ( not newcolor.isValid() ): return endIndex = index + 1 if ( self.propogateRight() ): endIndex = self.columnCount() for i in range(index, endIndex): item.setColorAt(i-1, newcolor)