Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
def _interactive_color_dialog(callback):
    from PyQt4.QtGui import QColorDialog

    dialog = QColorDialog()

    dialog.currentColorChanged.connect(callback)
    dialog.show()
    return dialog
Exemplo n.º 6
0
 def openColorDialog(self, initcolor):
     colordialog = QColorDialog()
     selectedcolor = colordialog.getColor(initcolor, None,
                                          'Please select a color')
     if selectedcolor.isValid():
         return selectedcolor
     else:
         return initcolor
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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()
Exemplo n.º 10
0
    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())
Exemplo n.º 11
0
    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())
Exemplo n.º 12
0
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())
Exemplo n.º 13
0
 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
Exemplo n.º 14
0
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
Exemplo n.º 15
0
    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()
Exemplo n.º 16
0
 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()
Exemplo n.º 18
0
 def onColorPicker(self):
     dialog = QColorDialog()
     dialog.setCurrentColor(self._color)
     if dialog.exec_():
         self.set_color(dialog.currentColor())
Exemplo n.º 19
0
 def tableViewCellDoubleClicked(self, modelIndex):
     if modelIndex.column() == LabelListView.ColumnID.Color:
         color = QColorDialog().getColor()
         self.model().setData(modelIndex, color)
Exemplo n.º 20
0
 def SetProductColour(self):
     picker = QColorDialog()
     picker.exec_()
     if picker.selectedColor() is not None:
         self._CurrentReaction.SetProductColour(picker.selectedColor())
Exemplo n.º 21
0
    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()
Exemplo n.º 22
0
 def onPmapColor(self):
     self.setPmapColor(QColorDialog().getColor())
Exemplo n.º 23
0
 def onColor(self):
     color=QColorDialog().getColor()
     self.setColor(color)