本文整理汇总了Python中qgis.PyQt.QtWidgets.QCheckBox.isChecked方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.isChecked方法的具体用法?Python QCheckBox.isChecked怎么用?Python QCheckBox.isChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QCheckBox
的用法示例。
在下文中一共展示了QCheckBox.isChecked方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ModelerParameterDefinitionDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
self.verticalLayout.addWidget(self.requiredCheck)
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |
QDialogButtonBox.Ok)
self.buttonBox.setObjectName('buttonBox')
self.buttonBox.accepted.connect(self.okPressed)
self.buttonBox.rejected.connect(self.cancelPressed)
self.verticalLayout.addStretch()
self.verticalLayout.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout)
def okPressed(self):
description = str(self.nameTextBox.text())
if description.strip() == '':
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Invalid parameter name'))
return
if self.param is None:
validChars = \
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
safeName = ''.join(c for c in description if c in validChars)
name = safeName.lower()
i = 2
while name in self.alg.inputs:
name = safeName.lower() + str(i)
else:
name = self.param.name()
if (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or
isinstance(self.param, ParameterBoolean)):
self.param = ParameterBoolean(name, description, self.state.isChecked())
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or
isinstance(self.param, ParameterTableField)):
if self.parentCombo.currentIndex() < 0:
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Wrong or missing parameter values'))
return
parent = self.parentCombo.currentData()
datatype = self.datatypeCombo.currentData()
self.param = ParameterTableField(name, description, parent, datatype, multiple=self.multipleCheck.isChecked())
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
isinstance(self.param, ParameterRaster)):
self.param = ParameterRaster(
name, description)
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE or
isinstance(self.param, ParameterTable)):
self.param = ParameterTable(
name, description)
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or
isinstance(self.param, ParameterVector)):
self.param = ParameterVector(
name, description,
[self.shapetypeCombo.currentIndex() - 1])
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE or
isinstance(self.param, ParameterMultipleInput)):
self.param = ParameterMultipleInput(
name, description,
self.datatypeCombo.currentIndex() - 1)
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_NUMBER or
isinstance(self.param, ParameterNumber)):
try:
vmin = self.minTextBox.text().strip()
if vmin == '':
示例2: ModelerParameterDefinitionDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |
QDialogButtonBox.Ok)
self.buttonBox.setObjectName('buttonBox')
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.verticalLayout.addStretch()
self.verticalLayout.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout)
def accept(self):
description = self.nameTextBox.text()
if description.strip() == '':
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Invalid parameter name'))
return
if self.param is None:
validChars = \
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
safeName = ''.join(c for c in description if c in validChars)
name = safeName.lower()
i = 2
while self.alg.parameterDefinition(name):
name = safeName.lower() + str(i)
i += 1
else:
name = self.param.name()
if (self.paramType == parameters.PARAMETER_BOOLEAN or
isinstance(self.param, QgsProcessingParameterBoolean)):
self.param = QgsProcessingParameterBoolean(name, description, self.state.isChecked())
elif (self.paramType == parameters.PARAMETER_TABLE_FIELD or
isinstance(self.param, QgsProcessingParameterField)):
if self.parentCombo.currentIndex() < 0:
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Wrong or missing parameter values'))
return
parent = self.parentCombo.currentData()
datatype = self.datatypeCombo.currentData()
default = self.defaultTextBox.text()
if not default:
default = None
self.param = QgsProcessingParameterField(name, description, defaultValue=default,
parentLayerParameterName=parent, type=datatype,
allowMultiple=self.multipleCheck.isChecked())
elif (self.paramType == parameters.PARAMETER_BAND or
isinstance(self.param, QgsProcessingParameterBand)):
if self.parentCombo.currentIndex() < 0:
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Wrong or missing parameter values'))
return
parent = self.parentCombo.currentData()
self.param = QgsProcessingParameterBand(name, description, None, parent)
elif (self.paramType == parameters.PARAMETER_MAP_LAYER or
isinstance(self.param, QgsProcessingParameterMapLayer)):
self.param = QgsProcessingParameterMapLayer(
name, description)
elif (self.paramType == parameters.PARAMETER_RASTER or
isinstance(self.param, QgsProcessingParameterRasterLayer)):
self.param = QgsProcessingParameterRasterLayer(
name, description)
elif (self.paramType == parameters.PARAMETER_TABLE or
isinstance(self.param, QgsProcessingParameterVectorLayer)):
示例3: ModelerParameterDefinitionDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |
QDialogButtonBox.Ok)
self.buttonBox.setObjectName('buttonBox')
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.verticalLayout.addStretch()
self.verticalLayout.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout)
def accept(self):
description = str(self.nameTextBox.text())
if description.strip() == '':
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Invalid parameter name'))
return
if self.param is None:
validChars = \
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
safeName = ''.join(c for c in description if c in validChars)
name = safeName.lower()
i = 2
while self.alg.parameterDefinition(name):
name = safeName.lower() + str(i)
i += 1
else:
name = self.param.name()
if (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or
isinstance(self.param, QgsProcessingParameterBoolean)):
self.param = QgsProcessingParameterBoolean(name, description, self.state.isChecked())
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or
isinstance(self.param, QgsProcessingParameterField)):
if self.parentCombo.currentIndex() < 0:
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Wrong or missing parameter values'))
return
parent = self.parentCombo.currentData()
datatype = self.datatypeCombo.currentData()
default = self.defaultTextBox.text()
if not default:
default = None
self.param = QgsProcessingParameterField(name, description, defaultValue=default,
parentLayerParameterName=parent, type=datatype,
allowMultiple=self.multipleCheck.isChecked())
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BAND or
isinstance(self.param, QgsProcessingParameterBand)):
if self.parentCombo.currentIndex() < 0:
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Wrong or missing parameter values'))
return
parent = self.parentCombo.currentData()
self.param = QgsProcessingParameterBand(name, description, None, parent)
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_MAP_LAYER or
isinstance(self.param, QgsProcessingParameterMapLayer)):
self.param = QgsProcessingParameterMapLayer(
name, description)
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
isinstance(self.param, QgsProcessingParameterRasterLayer)):
self.param = QgsProcessingParameterRasterLayer(
name, description)
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE or
isinstance(self.param, QgsProcessingParameterVectorLayer)):
示例4: DialogOutputOptions
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import isChecked [as 别名]
class DialogOutputOptions(QDialog):
def __init__(self, interface, toolWindow, options):
QDialog.__init__(self, interface.mainWindow())
self.iface = interface
self.tool = toolWindow
self.options = options
self.setWindowTitle("Output Optionen")
main_widget = QWidget(self)
# Build up gui
hbox = QHBoxLayout()
saveLabel = QLabel("Speicherpfad")
self.pathField = QComboBox()
self.pathField.setMinimumWidth(400)
self.pathField.setSizePolicy(
QSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Fixed))
openButton = QPushButton()
openButton.setMaximumSize(QSize(27, 27))
icon = QIcon()
iconPath = os.path.join(os.path.dirname(os.path.dirname(__file__)),
'icons', 'icon_open.png')
icon.addPixmap(QPixmap(iconPath), QIcon.Normal,
QIcon.Off)
openButton.setIcon(icon)
openButton.setIconSize(QSize(24, 24))
openButton.clicked.connect(self.onOpenDialog)
hbox.addWidget(saveLabel)
hbox.addWidget(self.pathField)
hbox.addWidget(openButton)
# Create checkboxes
questionLabel = \
QLabel(u"Welche Produkte sollen erzeugt werden?")
self.checkBoxReport = QCheckBox(u"Technischer Bericht")
self.checkBoxPlot = QCheckBox(u"Diagramm")
self.checkBoxGeodata = \
QCheckBox(u"Shape-Daten der Stützen und Seillinie")
self.checkBoxCoords = \
QCheckBox(u"Koordinaten-Tabellen der Stützen und Seillinie")
# Set tick correctly
self.checkBoxReport.setChecked(self.options['report'])
self.checkBoxPlot.setChecked(self.options['plot'])
self.checkBoxGeodata.setChecked(self.options['geodata'])
self.checkBoxCoords.setChecked(self.options['coords'])
# Create Ok/Cancel Button and connect signal
buttonBox = QDialogButtonBox(main_widget)
buttonBox.setStandardButtons(QDialogButtonBox.Ok|
QDialogButtonBox.Cancel)
buttonBox.accepted.connect(self.Apply)
buttonBox.rejected.connect(self.Reject)
# Layout
container = QVBoxLayout(main_widget)
container.addLayout(hbox)
container.addWidget(QLabel(""))
container.addWidget(questionLabel)
container.addWidget(self.checkBoxReport)
container.addWidget(self.checkBoxPlot)
container.addWidget(self.checkBoxGeodata)
container.addWidget(self.checkBoxCoords)
container.addWidget(buttonBox)
container.setAlignment(Qt.AlignLeft)
self.setLayout(container)
def fillInDropDown(self, pathList):
for i in reversed(range(self.pathField.count())):
self.pathField.removeItem(i)
for path in reversed(pathList):
self.pathField.addItem(path)
def onOpenDialog(self):
title = u"Output Pfad auswählen"
directory = QFileDialog.getExistingDirectory(self, title,
self.options['outputPath'])
self.tool.updateCommonPathList(directory)
self.fillInDropDown(self.tool.commonPaths)
def Apply(self):
# Save checkbox status
self.options['outputPath'] = self.pathField.currentText()
self.options['report'] = int(self.checkBoxReport.isChecked())
self.options['plot'] = int(self.checkBoxPlot.isChecked())
self.options['geodata'] = int(self.checkBoxGeodata.isChecked())
self.options['coords'] = int(self.checkBoxCoords.isChecked())
# Update output location with currently selected path
self.tool.updateCommonPathList(self.pathField.currentText())
self.close()
def Reject(self):
self.close()
示例5: ModelerParameterDefinitionDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
| QDialogButtonBox.Ok)
self.buttonBox.setObjectName('buttonBox')
self.buttonBox.accepted.connect(self.okPressed)
self.buttonBox.rejected.connect(self.cancelPressed)
self.verticalLayout.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout)
def okPressed(self):
description = unicode(self.nameTextBox.text())
if description.strip() == '':
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Invalid parameter name'))
return
if self.param is None:
validChars = \
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
safeName = ''.join(c for c in description if c in validChars)
name = safeName.lower()
i = 2
while name in self.alg.inputs:
name = safeName.lower() + str(i)
else:
name = self.param.name
if self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN \
or isinstance(self.param, ParameterBoolean):
self.param = ParameterBoolean(name, description,
self.state.isChecked())
elif self.paramType in (
ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD,
ModelerParameterDefinitionDialog.PARAMETER_TABLE_MULTIPLE_FIELD)\
or isinstance(self.param, (ParameterTableField,
ParameterTableMultipleField)):
if self.parentCombo.currentIndex() < 0:
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Wrong or missing parameter values'))
return
parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
datatype = self.datatypeCombo.itemData(
self.datatypeCombo.currentIndex())
if (self.paramType ==
ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or
isinstance(self.param, ParameterTableField)):
self.param = ParameterTableField(
name, description, parent, datatype)
else:
self.param = ParameterTableMultipleField(
name, description, parent, datatype)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or \
isinstance(self.param, ParameterRaster):
self.param = ParameterRaster(
name, description,
self.yesNoCombo.currentIndex() == 1)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE or \
isinstance(self.param, ParameterTable):
self.param = ParameterTable(
name, description,
self.yesNoCombo.currentIndex() == 1)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or \