def btnLabelColorClick(self): dlgColor = QColorDialog(self) dlgColor.setCurrentColor(self.selectedLabelItem.fontColor()) result = dlgColor.exec_() if result == 1: self.labelColor = dlgColor.selectedColor() self.selectedLabelItem.setFontColor(self.labelColor)
def __init__(self, conteneur=None): if conteneur is None: conteneur = self QWidget.__init__(conteneur) colorWindow.__init__(conteneur) self.setupUi(conteneur) self.colorDialog = QColorDialog(self) self.listColor = [] self.changers = [u"Fond d'écran 3D", u"Arrière-plan"] self.changersVar = ["wallpaper", "background"] self.changedColor = [] for a in self.changers: self.comboBox.addItem(a) self.listColor.append(QColor(255, 255, 255)) self.changedColor.append(False) self.connect(self.toolButton, SIGNAL("released()"), self.chooseColor) self.connect(self.comboBox, SIGNAL("currentIndexChanged (int)"), self.changeColor) self.connect(self.buttonBox, SIGNAL("accepted ()"), self.apply) self.connect(self.buttonBox, SIGNAL("rejected ()"), self.hide) self.connect(self.colorDialog, SIGNAL("colorSelected ()"), self.finishChooseColor) self.changeColor()
def __init__(self, parent=None): super(PreferencesView, self).__init__(parent) self.setWindowTitle("Preferences") # self.setFixedSize(self.maximumSize()) # self.setMinimumSize(self.maximumSize()) # self.setMaximumSize(self.maximumSize()) # self.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.chemicalSimulationDt = self.createFloatingPointEditor() self.chemicalDiffusionDt = self.createFloatingPointEditor() self.chemicalPlotUpdateInterval = self.createFloatingPointEditor() self.chemicalDefaultSimulationRuntime = self.createFloatingPointEditor( ) self.chemicalGuiUpdateInterval = self.createFloatingPointEditor() self.chemicalSolver = QButtonGroup() self.chemicalSolvers = { "Exponential Euler": QRadioButton("Exponential Euler"), "Gillespie": QRadioButton("Gillespie"), "Runge Kutta": QRadioButton("Runge Kutta") } self.chemicalSimulationApply = QPushButton("Apply") self.chemicalSimulationCancel = QPushButton("Cancel") self.electricalSimulationDt = self.createFloatingPointEditor() self.electricalPlotUpdateInterval = self.createFloatingPointEditor() self.electricalDefaultSimulationRuntime = self.createFloatingPointEditor( ) self.electricalGuiUpdateInterval = self.createFloatingPointEditor() self.electricalSolver = QButtonGroup() self.electricalSolvers = { "Gillespie": QRadioButton("Gillespie"), "Runge Kutta": QRadioButton("Runge Kutta") } self.electricalSimulationApply = QPushButton("Apply") self.electricalSimulationCancel = QPushButton("Cancel") self.electricalVisualizationApply = QPushButton("Apply") self.electricalVisualizationCancel = QPushButton("Cancel") self.electricalBaseColorButton = QPushButton() self.electricalBaseColorDialog = QColorDialog() self.electricalPeakColorButton = QPushButton() self.electricalPeakColorDialog = QColorDialog() self.electricalBackgroundColorButton = QPushButton() self.electricalBackgroundColorDialog = QColorDialog() self.electricalBaseMembraneVoltage = self.createFloatingPointEditor() self.electricalPeakMembraneVoltage = self.createFloatingPointEditor() self.create()
def change_color(self, index): color = self.model().data(index, ColorRole) if color is None: return dlg = QColorDialog(QColor(*color)) if dlg.exec(): color = dlg.selectedColor() self.model().setData(index, color.getRgb(), ColorRole)
def _interactive_color_dialog(callback): from PyQt4.QtGui import QColorDialog dialog = QColorDialog() dialog.currentColorChanged.connect(callback) dialog.show() return dialog
def openColorDialog(self, initcolor): colordialog = QColorDialog() selectedcolor = colordialog.getColor(initcolor, None, 'Please select a color') if selectedcolor.isValid(): return selectedcolor else: return initcolor
def change_color(self, index): """Invoke palette editor and set the color""" color = self.model().data(index, ColorRole) if color is None: return dlg = QColorDialog(QColor(*color)) if dlg.exec(): color = dlg.selectedColor() self.model().setData(index, color.getRgb(), ColorRole)
def selectColour(): colour = colourAttr.getInstance(self._currentScheme) currentColour = getattr(colour, colourType) colourDialog = QColorDialog(currentColour, self) if colourDialog.exec_(): selected = colourDialog.selectedColor() if selected != currentColour: self._styleButton(button, selected) setattr(colour, colourType, selected)
def _select(self, nbr): col = QColorDialog() col = QtGui.QColorDialog.getColor() if col.isValid() and self._mem: logger.info(col.red()) self._mem.leds[nbr].set(r=col.red(), g=col.green(), b=col.blue()) self.sender().setStyleSheet( "background-color: rgb({},{},{})".format( col.red(), col.green(), col.blue())) self._write_led_output()
def onColorPicker(self): '''Show color-picker dialog to select color.''' dlg = QColorDialog(self) dlg.setStyleSheet("background-color: %s" % self.defaultColor) if self._color: dlg.setCurrentColor(QColor(self._color)) if dlg.exec_(): self.set_color(dlg.currentColor().name())
def onColorPicker(self): ''' Show color-picker dialog to select color. Qt will use the native dialog by default. ''' dlg = QColorDialog(self) if self._color: dlg.setCurrentColor(QColor(self._color)) if dlg.exec_(): self.setColor(dlg.currentColor().name())
class ColorPicker(QWidget): """A widget that shows a colored box and pops up a color dialog.""" color_dialog = QColorDialog() def __init__(self, plot_config): QWidget.__init__(self) self.plot_config = plot_config size = 20 self.setMaximumSize(QSize(size, size)) self.setMinimumSize(QSize(size, size)) self.setToolTip("Click to change color!") def paintEvent(self, paintevent): """Paints the box""" painter = QPainter(self) rect = self.contentsRect() rect.setWidth(rect.width() - 1) rect.setHeight(rect.height() - 1) painter.drawRect(rect) rect.setX(rect.x() + 1) rect.setY(rect.y() + 1) painter.fillRect(rect, self._getColor()) def _setColor(self, color): """Set the color of this picker.""" self.plot_config.color = (color.redF(), color.greenF(), color.blueF()) self.update() def _getColor(self): """Return the color of this picker as QColor.""" color = self.plot_config.color return QColor(int(color[0] * 255), int(color[1] * 255), int(color[2] * 255)) def mouseDoubleClickEvent(self, event): self.color_dialog.setCurrentColor(self._getColor()) status = self.color_dialog.exec_() if status == QDialog.Accepted: self._setColor(self.color_dialog.selectedColor()) def mousePressEvent(self, event): self.color_dialog.setCurrentColor(self._getColor()) status = self.color_dialog.exec_() if status == QDialog.Accepted: self._setColor(self.color_dialog.selectedColor())
def onClick(self, iface, wdg, mdl, plotlibrary, index): #action when clicking the tableview item = mdl.itemFromIndex(index) name = mdl.item(index.row(), 5).data(Qt.EditRole) if index.column() == 1: #modifying color color = QColorDialog().getColor(item.data(Qt.BackgroundRole)) mdl.setData(mdl.index(item.row(), 1, QModelIndex()), color, Qt.BackgroundRole) PlottingTool().changeColor(wdg, plotlibrary, color, name) elif index.column() == 0: #modifying checkbox isVisible = not (item.data(Qt.CheckStateRole)) mdl.setData(mdl.index(item.row(), 0, QModelIndex()), isVisible, Qt.CheckStateRole) PlottingTool().changeAttachCurve(wdg, plotlibrary, isVisible, name) else: return
def getColor( parent=None, title="", color=None, alpha=False, ): """Ask the user a color.""" global _savedColor if color is None: color = _savedColor dlg = QColorDialog(color, parent) options = QColorDialog.ColorDialogOptions() if alpha: options |= QColorDialog.ShowAlphaChannel if not QSettings().value("native_dialogs/colordialog", True, bool): options |= QColorDialog.DontUseNativeDialog dlg.setOptions(options) dlg.setWindowTitle(title or app.caption(_("Select Color"))) if dlg.exec_(): _savedColor = dlg.selectedColor() return _savedColor
def _on_pick_tree(self, event): """a matplotlib callback function for when a tree is clicked on""" if event.artist != self._treepoints: # print "you clicked on something other than a node" return True ind = event.ind[0] self.tree_selected = self._tree_list[ind] print "tree clicked on", self.tree_selected # launch a color selector dialog and color # all subtrees by the selected color color_dialog = QColorDialog(parent=self) color_dialog.exec_() if color_dialog.result(): color = color_dialog.selectedColor() rgba = color.getRgbF() # red green blue alpha print "color", rgba rgb = rgba[:3] for tree in self.tree_selected.get_all_trees(): tree.data["colour"] = rgb self.redraw_disconnectivity_graph()
def onBrushColor(self): self.setBrushColor(QColorDialog().getColor())
def __init__(self, parent=None): QLabel.__init__(self, parent) self.colorDialog = QColorDialog() self.setToolTip("Choose section color") self.selectedColor = "white" self.updateLabelColor()
def onColorPicker(self): dialog = QColorDialog() dialog.setCurrentColor(self._color) if dialog.exec_(): self.set_color(dialog.currentColor())
def tableViewCellDoubleClicked(self, modelIndex): if modelIndex.column() == LabelListView.ColumnID.Color: color = QColorDialog().getColor() self.model().setData(modelIndex, color)
def SetProductColour(self): picker = QColorDialog() picker.exec_() if picker.selectedColor() is not None: self._CurrentReaction.SetProductColour(picker.selectedColor())
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', '{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.rightDock = MapSwipeRightDockWidget() self.bottomDock = MapSwipeBottomDockWidget() self.selectDock = MapSwipeDockWidget() # Declare instance attributes self.actions = [] self.menu = self.tr(u'&MapSwipe') self.toolbar = self.iface.addToolBar(u'MapSwipe') self.toolbar.setObjectName(u'MapSwipe') self.selectDock.startButton.clicked.connect(self.startButtonClicked) self.selectDock.stopButton.clicked.connect(self.stopButtonClicked) self.selectDock.colorChooserButton.clicked.connect( self.colorChoseButtonClicked) self.selectDock.spinBoxOpacity.valueChanged.connect( self.opacityValueChanged) QgsMapLayerRegistry.instance().layersRemoved.connect( self.checkActiveLayerRemoved) self.overlayMap = SwipeMap(self.iface.mapCanvas()) self.overlayMap.hide() self.layerId = None self.rectColor = QColor("red") self.overlayOpacity = 1.0 self.firstRun = True self.colorDialog = QColorDialog(self.rectColor, parent=self.iface.mainWindow()) self.selectDock.colorChooserButton.setPalette(QPalette(self.rectColor)) # Setup the slider resolution and values self.bottomDock.Slider.setMaximum(swipeSliderMaximum) self.bottomDock.Slider.setTickInterval(swipeSliderMaximum / 100) self.rightDock.Slider.setMaximum(swipeSliderMaximum) self.rightDock.Slider.setTickInterval(swipeSliderMaximum / 100) self.rightDock.Slider.setValue(swipeSliderMaximum) self.bottomDock.Slider.setValue(swipeSliderMaximum / 2) self.init_default_settings()
def onPmapColor(self): self.setPmapColor(QColorDialog().getColor())
def onColor(self): color=QColorDialog().getColor() self.setColor(color)