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


Python QtWidgets.QColorDialog类代码示例

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


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

示例1: setBackgroundColour

    def setBackgroundColour(self):
        col = QColorDialog.getColor()

        if col.isValid():
            self.BACKGROUND_COLOUR = col
            self.dlg.ui.frmColour.setStyleSheet("QWidget { background-color: %s }"
                % self.BACKGROUND_COLOUR.name())
开发者ID:rudivs,项目名称:DistroMap,代码行数:7,代码来源:distromap.py

示例2: on_reliefClassTree_itemDoubleClicked

    def on_reliefClassTree_itemDoubleClicked(self, item, column):
        if not item:
            return

        if column == 0:
            d, ok = QInputDialog.getDouble(None,
                                           self.tr('Enter lower elevation class bound'),
                                           self.tr('Elevation'),
                                           float(item.text(0)),
                                           decimals=2)
            if ok:
                item.setText(0, str(d))
        elif column == 1:
            d, ok = QInputDialog.getDouble(None,
                                           self.tr('Enter upper elevation class bound'),
                                           self.tr('Elevation'),
                                           float(item.text(1)),
                                           decimals=2)
            if ok:
                item.setText(1, str(d))
        elif column == 2:
            c = QColorDialog.getColor(item.background(2).color(),
                                      None,
                                      self.tr('Select color for relief class'))
            if c.isValid():
                item.setBackground(2, QBrush(c))
开发者ID:cayetanobv,项目名称:QGIS,代码行数:26,代码来源:ReliefColorsWidget.py

示例3: __init__

    def __init__(self):
        QWidget.__init__(self)

        self.setWindowTitle(self.tr('Qdraw - Settings'))
        self.setFixedSize(320, 100)
        self.center()

        # default color
        self.color = QColor(60, 151, 255, 255)

        self.sld_opacity = QSlider(Qt.Horizontal, self)
        self.sld_opacity.setRange(0, 255)
        self.sld_opacity.setValue(255)
        self.sld_opacity.tracking = True
        self.sld_opacity.valueChanged.connect(self.handler_opacitySliderValue)
        self.lbl_opacity = QLabel(self.tr('Opacity') + ': 100%', self)

        self.dlg_color = QColorDialog(self)
        btn_chColor = QPushButton(self.tr('Change the drawing color'), self)
        btn_chColor.clicked.connect(self.handler_chColor)

        vbox = QVBoxLayout()
        vbox.addWidget(self.lbl_opacity)
        vbox.addWidget(self.sld_opacity)
        vbox.addWidget(btn_chColor)
        self.setLayout(vbox)
开发者ID:jeremyk6,项目名称:qdraw,代码行数:26,代码来源:qdrawsettings.py

示例4: setFill

 def setFill( self ):
     if self.profile == None: return
     if self.ax == None: return
     
     clr = QColorDialog.getColor( Qt.white, self, QCoreApplication.translate(
               "geopunt4QgisElevationDialog", "Kies de vulkleur") )
     if clr.isValid():
       xdata = np.array( [n[0] for n in self.profile ] ) * self.xscaleUnit[0]
       ydata = np.array( [n[3] for n in self.profile ] )
       self.ax.fill_between( xdata, ydata, -9999, color=clr.name() )
开发者ID:warrieka,项目名称:geopunt4Qgis,代码行数:10,代码来源:geopunt4QgisElevation.py

示例5: simple_Kolors

 def simple_Kolors(self):
     self.dlg.hide()
     self.NameColor = QColorDialog().getColor(QColor(self.red, self.green, self.blue)).name()
     self.dlg.show()
     #
     self.dlg.color_groupBox.setStyleSheet(str("background-color:") + self.NameColor + str(";"))
     self.dlg.color_lineEdit.setText(self.NameColor)
     #
     value = self.NameColor.lstrip('#')
     R1 = value[0:2]
     G2 = value[2:4]
     B3 = value[4:6]
     self.red = int(R1, 16)
     self.green = int(G2, 16)
     self.blue = int(B3, 16)
开发者ID:Hacked-Crew,项目名称:Magnetic-Declination,代码行数:15,代码来源:Magnetic_declination.py

示例6: MagneticDeclination


#.........这里部分代码省略.........
            QgsField("Lon WGS84", QVariant.Double),
            QgsField("Lat WGS84", QVariant.Double),
            QgsField("Epoch", QVariant.String),
            QgsField("h Unit", QVariant.String),
            QgsField("h WGS84", QVariant.Double),
            QgsField("Declinatio", QVariant.Double),
            QgsField("Annual", QVariant.Double),
            QgsField("value", QVariant.String)
            ])
        pointLayer.commitChanges()
        #
        feat = QgsFeature()
        feat.setGeometry(QgsGeometry.fromPointXY(self.pointRose))
        vaLue = (str(("VAR " + str(self.vAr) + str(self.Rdirection) + "\n" + "(" + str(self.Rdate2) + ")" + "\n\n\n\n" + str(self.Rheight2) + "\n" + "ANNUAL " + str(self.Rlevel) + str(self.annual))))
        #
        feat.setAttributes([
            self.simple_longitude,
            self.simple_latitude,
            str(self.Rdate),
            self.Runit,
            self.Rheight,
            self.Rdeclination,
            self.RdecliVar,
            vaLue
            ])
        layerData.addFeatures([feat])
        #
        svgStyleTN = {}
        svgStyleTN ['name'] = str(str(self.plugin_dir) + str("/img/Modern_nautical_compass_rose_TN.svg"))
        svgStyleTN ['size_unit'] = 'MapUnit'
        svgStyleTN ['size'] = str(self.distance)
        svgStyleTN ['angle_expression'] = '0'
        svgStyleTN ['outline_color'] = str(self.NameColor)
        svgStyleTN ['color'] = str(self.NameColor)
        svgStyleMN = {}
        svgStyleMN ['name'] = str(str(self.plugin_dir) + str("/img/Modern_nautical_compass_rose_MN.svg"))
        svgStyleMN ['size_unit'] = 'MapUnit'
        svgStyleMN ['size'] = str(self.distance)
        svgStyleMN ['angle_expression'] = 'Declinatio'
        svgStyleMN ['outline_color'] = str(self.NameColor)
        svgStyleMN ['color'] = str(self.NameColor)
        #
        layerTN = QgsSvgMarkerSymbolLayer.create(svgStyleTN)
        layerMN = QgsSvgMarkerSymbolLayer.create(svgStyleMN)
        pointLayer.renderer().symbols(QgsRenderContext())[0].appendSymbolLayer(layerTN)
        pointLayer.renderer().symbols(QgsRenderContext())[0].appendSymbolLayer(layerMN)
        pointLayer.renderer().symbol().symbolLayer(0).setSize(1)#
        #
        pal_layer=QgsPalLayerSettings()
        prop=QgsProperty()
        pc=QgsPropertyCollection('mycollection')
        #
        #settings.drawLabels = True
        pal_layer.fieldName="value"
        pal_layer.placement=QgsPalLayerSettings.OverPoint
        pc.setProperty(pal_layer.Family,"Arial Black")
        pc.setProperty(pal_layer.Color, QColor(self.red, self.green, self.blue))
        pc.setProperty(pal_layer.FontSizeUnit, "MapUnit")
        pc.setProperty(pal_layer.MultiLineAlignment, "Center")
        pc.setProperty(pal_layer.LabelRotation, float(self.Rdeclination))
        pc.setProperty(pal_layer.AlwaysShow, int(1))
        pc.setProperty(pal_layer.IsObstacle, int(0))
        pc.setProperty(pal_layer.Show, int(1))
        pc.setProperty(pal_layer.Size, self.distance*0.020)
        pal_layer.setDataDefinedProperties(pc)
        pal_layer.enabled=True
        labeler=QgsVectorLayerSimpleLabeling(pal_layer)
        pal_layer.showAll=True
        pal_layer.displayAll=True
        pointLayer.setLabeling(labeler)
        pointLayer.setLabelsEnabled(True)
        pointLayer.triggerRepaint()
        #
        QgsProject.instance().addMapLayer(pointLayer)
        self.iface.mapCanvas().refresh()


    def simple_Kolors(self):
        self.dlg.hide()
        self.NameColor = QColorDialog().getColor(QColor(self.red, self.green, self.blue)).name()
        self.dlg.show()
        #
        self.dlg.color_groupBox.setStyleSheet(str("background-color:") + self.NameColor + str(";"))
        self.dlg.color_lineEdit.setText(self.NameColor)
        #
        value = self.NameColor.lstrip('#')
        R1 = value[0:2]
        G2 = value[2:4]
        B3 = value[4:6]
        self.red = int(R1, 16)
        self.green = int(G2, 16)
        self.blue = int(B3, 16)


    def date_Error(self):
        QMessageBox.warning( self.iface.mainWindow(),"WARNING", self.formatted_lines[-1] )

    def simple_Cancel(self):
    #CLOSE
        self.dlg.close()
开发者ID:Hacked-Crew,项目名称:Magnetic-Declination,代码行数:101,代码来源:Magnetic_declination.py

示例7: QdrawSettings

class QdrawSettings(QWidget):
    """Window used to change settings (transparency/color)"""
    settingsChanged = pyqtSignal()

    def __init__(self):
        QWidget.__init__(self)

        self.setWindowTitle(self.tr('Qdraw - Settings'))
        self.setFixedSize(320, 100)
        self.center()

        # default color
        self.color = QColor(60, 151, 255, 255)

        self.sld_opacity = QSlider(Qt.Horizontal, self)
        self.sld_opacity.setRange(0, 255)
        self.sld_opacity.setValue(255)
        self.sld_opacity.tracking = True
        self.sld_opacity.valueChanged.connect(self.handler_opacitySliderValue)
        self.lbl_opacity = QLabel(self.tr('Opacity') + ': 100%', self)

        self.dlg_color = QColorDialog(self)
        btn_chColor = QPushButton(self.tr('Change the drawing color'), self)
        btn_chColor.clicked.connect(self.handler_chColor)

        vbox = QVBoxLayout()
        vbox.addWidget(self.lbl_opacity)
        vbox.addWidget(self.sld_opacity)
        vbox.addWidget(btn_chColor)
        self.setLayout(vbox)

    def tr(self, message):
        return QCoreApplication.translate('Qdraw', message)

    def handler_opacitySliderValue(self, val):
        self.color.setAlpha(val)
        self.lbl_opacity.setText(
            self.tr('Opacity')+': '+str(int((float(val) / 255) * 100))+'%')
        self.settingsChanged.emit()

    def handler_chColor(self):
        color = self.dlg_color.getColor(self.color)
        if color.isValid():
            color.setAlpha(self.color.alpha())
            self.color = color
            self.settingsChanged.emit()
            self.close()

    def getColor(self):
        return self.color

    def center(self):
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)

    def closeEvent(self, e):
        self.clear()
        e.accept()

    def clear(self):
        return
开发者ID:jeremyk6,项目名称:qdraw,代码行数:63,代码来源:qdrawsettings.py

示例8: choosePointsReplicasColor

	def choosePointsReplicasColor(self):
		dlg = QColorDialog(self.pointsReplicasColor, self)
		if dlg.exec_():
			self.setPointsReplicasColor( dlg.selectedColor() )
		dlg.deleteLater()
开发者ID:faunalia,项目名称:ps-speed,代码行数:5,代码来源:graph_settings_dialog.py

示例9: chooseLabelsColor

	def chooseLabelsColor(self):
		dlg = QColorDialog(self.labelsColor, self)
		if dlg.exec_():
			self.setLabelsColor( dlg.selectedColor() )
		dlg.deleteLater()
开发者ID:faunalia,项目名称:ps-speed,代码行数:5,代码来源:graph_settings_dialog.py

示例10: chooseTitleColor

	def chooseTitleColor(self):
		dlg = QColorDialog(self.titleColor, self)
		if dlg.exec_():
			self.setTitleColor( dlg.selectedColor() )
		dlg.deleteLater()
开发者ID:faunalia,项目名称:ps-speed,代码行数:5,代码来源:graph_settings_dialog.py

示例11: chooseLinesThrendColor

	def chooseLinesThrendColor(self):
		dlg = QColorDialog(self.linesThrendColor, self)
		if dlg.exec_():
			self.setLinesThrendColor( dlg.selectedColor() )
		dlg.deleteLater()
开发者ID:faunalia,项目名称:ps-speed,代码行数:5,代码来源:graph_settings_dialog.py


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