本文整理汇总了Python中qgis.PyQt.QtGui.QColor.name方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.name方法的具体用法?Python QColor.name怎么用?Python QColor.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GraphSettings_Dlg
# 需要导入模块: from qgis.PyQt.QtGui import QColor [as 别名]
# 或者: from qgis.PyQt.QtGui.QColor import name [as 别名]
class GraphSettings_Dlg(QDialog, Ui_Dialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.setupUi(self)
self.titleBoldBtn.hide()
self.titleItalicBtn.hide()
self.labelsBoldBtn.hide()
self.labelsItalicBtn.hide()
# remove fonts matplotlib doesn't load
for index in range(self.titleFontCombo.count()-1, -1, -1):
found = False
family = unicode( self.titleFontCombo.itemText( index ) )
try:
props = self.findFont( {'family':family} )
if family == props['family']:
found = True
except Exception:
pass
if not found:
self.titleFontCombo.removeItem( index )
self.labelsFontCombo.removeItem( index )
self.initProps()
self.titleColorBtn.clicked.connect(self.chooseTitleColor)
self.labelsColorBtn.clicked.connect(self.chooseLabelsColor)
self.pointsColorBtn.clicked.connect(self.choosePointsColor)
self.pointsReplicasColorBtn.clicked.connect(self.choosePointsReplicasColor)
self.linesColorBtn.clicked.connect(self.chooseLinesColor)
self.linesThrendColorBtn.clicked.connect(self.chooseLinesThrendColor)
def choosePointsColor(self):
dlg = QColorDialog(self.pointsColor, self)
if dlg.exec_():
self.setPointsColor( dlg.selectedColor() )
dlg.deleteLater()
def setPointsColor(self, color):
self.pointsColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.pointsColor )
self.pointsColorBtn.setIcon( QIcon(pixmap) )
def pointsProps(self):
props = {
'marker' : 's',
'color' : self.pointsColor.name()
}
return props
def setPointsProps(self, props):
self.setPointsColor( props.get('color', 'black') )
def choosePointsReplicasColor(self):
dlg = QColorDialog(self.pointsReplicasColor, self)
if dlg.exec_():
self.setPointsReplicasColor( dlg.selectedColor() )
dlg.deleteLater()
def setPointsReplicasColor(self, color):
self.pointsReplicasColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.pointsReplicasColor )
self.pointsReplicasColorBtn.setIcon( QIcon(pixmap) )
def pointsReplicasProps(self):
props = {
'marker' : 's',
'color' : self.pointsReplicasColor.name(),
}
return props
def setPointsReplicasProps(self, props):
self.setPointsReplicasColor( props.get('color', 'blue') )
def chooseLinesColor(self):
dlg = QColorDialog(self.linesColor, self)
if dlg.exec_():
self.setLinesColor( dlg.selectedColor() )
dlg.deleteLater()
def setLinesColor(self, color):
self.linesColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.linesColor )
self.linesColorBtn.setIcon( QIcon(pixmap) )
def linesProps(self):
props = {
'color' : self.linesColor.name()
}
return props
def setLinesProps(self, props):
self.setLinesColor( props.get('color', 'black') )
def chooseLinesThrendColor(self):
#.........这里部分代码省略.........
示例2: DistroMap
# 需要导入模块: from qgis.PyQt.QtGui import QColor [as 别名]
# 或者: from qgis.PyQt.QtGui.QColor import name [as 别名]
class DistroMap(object):
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = QFileInfo(QgsApplication.qgisSettingsDirPath()).path() + "/python/plugins/distromap"
# initialize locale
localePath = ""
locale = QSettings().value("locale/userLocale")[0:2]
if QFileInfo(self.plugin_dir).exists():
localePath = self.plugin_dir + "/i18n/distromap_" + locale + ".qm"
if QFileInfo(localePath).exists():
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.dlg = DistroMapDialog()
def confirm(self):
# runs when OK button is pressed
# initialise input parameters
self.BASE_LAYER = self.dlg.ui.comboBase.currentItemData()
self.SECONDARY_LAYER = self.dlg.ui.comboSecondary.currentItemData()
self.SURFACE_LAYER = self.dlg.ui.comboSurface.currentItemData()
self.LOCALITIES_LAYER = self.dlg.ui.comboLocalities.currentItemData()
self.TAXON_FIELD_INDEX = self.dlg.ui.comboTaxonField.currentItemData()[0]
self.GRID_LAYER = self.dlg.ui.comboGrid.currentItemData()
self.X_MIN = float(self.dlg.ui.leMinX.text())
self.Y_MIN = float(self.dlg.ui.leMinY.text())
self.X_MAX = float(self.dlg.ui.leMaxX.text())
self.Y_MAX = float(self.dlg.ui.leMaxY.text())
self.OUT_WIDTH = self.dlg.ui.spnOutWidth.value()
self.OUT_HEIGHT = self.dlg.ui.spnOutHeight.value()
self.OUT_DIR = self.dlg.ui.leOutDir.text()
try:
self.getUniqueValues()
except:
message = "Could not get unique values from localities layer. "
message += "Check that the localities layer and taxon identifier "
message += "field are properly specified."
QMessageBox.information(self.dlg,"Distribution Map Generator",
message)
return
question = "This will generate " + str(self.UNIQUE_COUNT)
question += " maps. Are you sure you want to continue?"
reply = QMessageBox.question(self.dlg,'Distribution Map Generator',
question,
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
self.GRID_INDEX = QgsSpatialIndex()
for feat in getLayerFromId(self.GRID_LAYER).getFeatures():
self.GRID_INDEX.insertFeature(feat)
if reply == QMessageBox.Yes:
try:
self.process()
except QgsCsException:
return
except Exception as ex:
log(ex)
return
QMessageBox.information(self.dlg,"Distribution Map Generator",
"Map processing complete.")
self.dlg.ui.progressBar.setValue(0)
QDialog.accept(self.dlg)
else:
return
def initGui(self):
# Create action that will start plugin configuration
self.action = QAction(
QIcon(self.plugin_dir + "/icon.svg"),
u"Distribution Map Generator...", self.iface.mainWindow())
# connect the action to the run method
self.action.triggered.connect(self.run)
self.dlg.ui.buttonBox.accepted.connect(self.confirm)
# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu(u"&Distribution Map Generator", self.action)
# Set colour for output background colour chooser:
self.BACKGROUND_COLOUR = QColor(192,192,255)
self.dlg.ui.frmColour.setStyleSheet("QWidget { background-color: %s }"
% self.BACKGROUND_COLOUR.name())
def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu(u"&Distribution Map Generator", self.action)
self.iface.removeToolBarIcon(self.action)
def loadTaxonFields(self):
#.........这里部分代码省略.........