本文整理汇总了Python中qgis.PyQt.QtWidgets.QCheckBox.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.setChecked方法的具体用法?Python QCheckBox.setChecked怎么用?Python QCheckBox.setChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QCheckBox
的用法示例。
在下文中一共展示了QCheckBox.setChecked方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extra_keywords_to_widgets
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
def extra_keywords_to_widgets(extra_keyword_definition):
"""Create widgets for extra keyword.
:param extra_keyword_definition: An extra keyword definition.
:type extra_keyword_definition: dict
:return: QCheckBox and The input widget
:rtype: (QCheckBox, QWidget)
"""
# Check box
check_box = QCheckBox(extra_keyword_definition['name'])
check_box.setToolTip(extra_keyword_definition['description'])
check_box.setChecked(True)
# Input widget
if extra_keyword_definition['type'] == float:
input_widget = QDoubleSpinBox()
input_widget.setMinimum(extra_keyword_definition['minimum'])
input_widget.setMaximum(extra_keyword_definition['maximum'])
input_widget.setSuffix(extra_keyword_definition['unit_string'])
elif extra_keyword_definition['type'] == int:
input_widget = QSpinBox()
input_widget.setMinimum(extra_keyword_definition['minimum'])
input_widget.setMaximum(extra_keyword_definition['maximum'])
input_widget.setSuffix(extra_keyword_definition['unit_string'])
elif extra_keyword_definition['type'] == str:
if extra_keyword_definition.get('options'):
input_widget = QComboBox()
options = extra_keyword_definition['options']
for option in options:
input_widget.addItem(
option['name'],
option['key'],
)
default_option_index = input_widget.findData(
extra_keyword_definition['default_option'])
input_widget.setCurrentIndex(default_option_index)
else:
input_widget = QLineEdit()
elif extra_keyword_definition['type'] == datetime:
input_widget = QDateTimeEdit()
input_widget.setCalendarPopup(True)
input_widget.setDisplayFormat('hh:mm:ss, d MMM yyyy')
input_widget.setDateTime(datetime.now())
else:
raise Exception
input_widget.setToolTip(extra_keyword_definition['description'])
# Signal
# noinspection PyUnresolvedReferences
check_box.stateChanged.connect(input_widget.setEnabled)
return check_box, input_widget
示例2: ModelerParameterDefinitionDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
class ModelerParameterDefinitionDialog(QDialog):
PARAMETER_NUMBER = 'Number'
PARAMETER_RASTER = 'Raster layer'
PARAMETER_TABLE = 'Table'
PARAMETER_VECTOR = 'Vector layer'
PARAMETER_STRING = 'String'
PARAMETER_EXPRESSION = 'Expression'
PARAMETER_BOOLEAN = 'Boolean'
PARAMETER_TABLE_FIELD = 'Table field'
PARAMETER_EXTENT = 'Extent'
PARAMETER_FILE = 'File'
PARAMETER_POINT = 'Point'
PARAMETER_CRS = 'CRS'
PARAMETER_MULTIPLE = 'Multiple input'
paramTypes = [
PARAMETER_BOOLEAN,
PARAMETER_EXTENT,
PARAMETER_FILE,
PARAMETER_NUMBER,
PARAMETER_RASTER,
PARAMETER_STRING,
PARAMETER_EXPRESSION,
PARAMETER_TABLE,
PARAMETER_TABLE_FIELD,
PARAMETER_VECTOR,
PARAMETER_POINT,
PARAMETER_CRS,
PARAMETER_MULTIPLE
]
def __init__(self, alg, paramType=None, param=None):
self.alg = alg
self.paramType = paramType
self.param = param
QDialog.__init__(self)
self.setModal(True)
self.setupUi()
def setupUi(self):
self.setWindowTitle(self.tr('Parameter definition'))
self.setMinimumWidth(300)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setMargin(20)
self.label = QLabel(self.tr('Parameter name'))
self.verticalLayout.addWidget(self.label)
self.nameTextBox = QLineEdit()
self.verticalLayout.addWidget(self.nameTextBox)
if isinstance(self.param, QgsProcessingParameterDefinition):
self.nameTextBox.setText(self.param.description())
if self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or \
isinstance(self.param, ParameterBoolean):
self.state = QCheckBox()
self.state.setText(self.tr('Checked'))
self.state.setChecked(False)
if self.param is not None:
self.state.setChecked(bool(self.param.value))
self.verticalLayout.addWidget(self.state)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or \
isinstance(self.param, ParameterTableField):
self.verticalLayout.addWidget(QLabel(self.tr('Parent layer')))
self.parentCombo = QComboBox()
idx = 0
for param in list(self.alg.inputs.values()):
if isinstance(param.param, (ParameterVector, ParameterTable)):
self.parentCombo.addItem(param.param.description(), param.param.name())
if self.param is not None:
if self.param.parent == param.param.name():
self.parentCombo.setCurrentIndex(idx)
idx += 1
self.verticalLayout.addWidget(self.parentCombo)
# add the datatype selector
self.verticalLayout.addWidget(QLabel(self.tr('Allowed data type')))
self.datatypeCombo = QComboBox()
self.datatypeCombo.addItem(self.tr('Any'), -1)
self.datatypeCombo.addItem(self.tr('Number'), 0)
self.datatypeCombo.addItem(self.tr('String'), 1)
self.datatypeCombo.addItem(self.tr('Date/time'), 2)
self.verticalLayout.addWidget(self.datatypeCombo)
if self.param is not None and self.param.datatype is not None:
# QComboBoxes indexes start at 0,
# self.param.datatype start with -1 that is why I need to do +1
datatypeIndex = self.param.datatype + 1
self.datatypeCombo.setCurrentIndex(datatypeIndex)
self.multipleCheck = QCheckBox()
self.multipleCheck.setText(self.tr('Accept multiple fields'))
self.multipleCheck.setChecked(False)
if self.param is not None:
self.multipleCheck.setChecked(self.param.multiple)
self.verticalLayout.addWidget(self.multipleCheck)
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or
#.........这里部分代码省略.........
示例3: initWidgets
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
#.........这里部分代码省略.........
self.wrappers[param.name()] = wrapper
# For compatibility with 3.x API, we need to check whether the wrapper is
# the deprecated WidgetWrapper class. If not, it's the newer
# QgsAbstractProcessingParameterWidgetWrapper class
# TODO QGIS 4.0 - remove
is_python_wrapper = issubclass(wrapper.__class__, WidgetWrapper)
if not is_python_wrapper:
wrapper.setWidgetContext(widget_context)
widget = wrapper.createWrappedWidget(self.processing_context)
wrapper.registerProcessingContextGenerator(self.context_generator)
else:
widget = wrapper.widget
if self.in_place and param.name() in ('INPUT', 'OUTPUT'):
# don't show the input/output parameter widgets in in-place mode
# we still need to CREATE them, because other wrappers may need to interact
# with them (e.g. those parameters which need the input layer for field
# selections/crs properties/etc)
continue
if widget is not None:
if is_python_wrapper:
widget.setToolTip(param.toolTip())
if isinstance(param, QgsProcessingParameterFeatureSource):
layout = QHBoxLayout()
layout.setSpacing(6)
layout.setMargin(0)
layout.addWidget(widget)
button = QToolButton()
icon = QIcon(os.path.join(pluginPath, 'images', 'iterate.png'))
button.setIcon(icon)
button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
button.setToolTip(self.tr('Iterate over this layer, creating a separate output for every feature in the layer'))
button.setCheckable(True)
layout.addWidget(button)
layout.setAlignment(button, Qt.AlignTop)
self.iterateButtons[param.name()] = button
button.toggled.connect(self.buttonToggled)
widget = QWidget()
widget.setLayout(layout)
label = None
if not is_python_wrapper:
label = wrapper.createWrappedLabel()
else:
label = wrapper.label
if label is not None:
if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced:
self.layoutAdvanced.addWidget(label)
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, label)
elif is_python_wrapper:
desc = param.description()
if isinstance(param, QgsProcessingParameterExtent):
desc += self.tr(' (xmin, xmax, ymin, ymax)')
if isinstance(param, QgsProcessingParameterPoint):
desc += self.tr(' (x, y)')
if param.flags() & QgsProcessingParameterDefinition.FlagOptional:
desc += self.tr(' [optional]')
widget.setText(desc)
if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced:
self.layoutAdvanced.addWidget(widget)
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, widget)
for output in self.alg.destinationParameterDefinitions():
if output.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
if self.in_place and param.name() in ('INPUT', 'OUTPUT'):
continue
label = QLabel(output.description())
widget = DestinationSelectionPanel(output, self.alg)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
if isinstance(output, (QgsProcessingParameterRasterDestination, QgsProcessingParameterFeatureSink, QgsProcessingParameterVectorDestination)):
check = QCheckBox()
check.setText(QCoreApplication.translate('ParametersPanel', 'Open output file after running algorithm'))
def skipOutputChanged(checkbox, skipped):
checkbox.setEnabled(not skipped)
if skipped:
checkbox.setChecked(False)
check.setChecked(not widget.outputIsSkipped())
check.setEnabled(not widget.outputIsSkipped())
widget.skipOutputChanged.connect(partial(skipOutputChanged, check))
self.layoutMain.insertWidget(self.layoutMain.count() - 1, check)
self.checkBoxes[output.name()] = check
widget.setToolTip(param.toolTip())
self.outputWidgets[output.name()] = widget
for wrapper in list(self.wrappers.values()):
wrapper.postInitialize(list(self.wrappers.values()))
示例4: ModelerParameterDefinitionDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
class ModelerParameterDefinitionDialog(QDialog):
def __init__(self, alg, paramType=None, param=None):
self.alg = alg
self.paramType = paramType
self.param = param
QDialog.__init__(self)
self.setModal(True)
self.setupUi()
settings = QgsSettings()
self.restoreGeometry(settings.value("/Processing/modelParametersDefinitionDialogGeometry", QByteArray()))
def closeEvent(self, event):
settings = QgsSettings()
settings.setValue("/Processing/modelParametersDefinitionDialogGeometry", self.saveGeometry())
super(ModelerParameterDefinitionDialog, self).closeEvent(event)
def setupUi(self):
self.setWindowTitle(self.tr('Parameter Definition'))
self.setMinimumWidth(300)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setMargin(20)
self.label = QLabel(self.tr('Parameter name'))
self.verticalLayout.addWidget(self.label)
self.nameTextBox = QLineEdit()
self.verticalLayout.addWidget(self.nameTextBox)
if isinstance(self.param, QgsProcessingParameterDefinition):
self.nameTextBox.setText(self.param.description())
if self.paramType == parameters.PARAMETER_BOOLEAN or \
isinstance(self.param, QgsProcessingParameterBoolean):
self.state = QCheckBox()
self.state.setText(self.tr('Checked'))
self.state.setChecked(False)
if self.param is not None:
self.state.setChecked(bool(self.param.defaultValue()))
self.verticalLayout.addWidget(self.state)
elif self.paramType == parameters.PARAMETER_TABLE_FIELD or \
isinstance(self.param, QgsProcessingParameterField):
self.verticalLayout.addWidget(QLabel(self.tr('Parent layer')))
self.parentCombo = QComboBox()
idx = 0
for param in list(self.alg.parameterComponents().values()):
definition = self.alg.parameterDefinition(param.parameterName())
if isinstance(definition, (QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer)):
self.parentCombo.addItem(definition.description(), definition.name())
if self.param is not None:
if self.param.parentLayerParameterName() == definition.name():
self.parentCombo.setCurrentIndex(idx)
idx += 1
self.verticalLayout.addWidget(self.parentCombo)
# add the datatype selector
self.verticalLayout.addWidget(QLabel(self.tr('Allowed data type')))
self.datatypeCombo = QComboBox()
self.datatypeCombo.addItem(self.tr('Any'), -1)
self.datatypeCombo.addItem(self.tr('Number'), 0)
self.datatypeCombo.addItem(self.tr('String'), 1)
self.datatypeCombo.addItem(self.tr('Date/time'), 2)
self.verticalLayout.addWidget(self.datatypeCombo)
if self.param is not None and self.param.dataType() is not None:
# QComboBoxes indexes start at 0,
# self.param.datatype start with -1 that is why I need to do +1
datatypeIndex = self.param.dataType() + 1
self.datatypeCombo.setCurrentIndex(datatypeIndex)
self.multipleCheck = QCheckBox()
self.multipleCheck.setText(self.tr('Accept multiple fields'))
self.multipleCheck.setChecked(False)
if self.param is not None:
self.multipleCheck.setChecked(self.param.allowMultiple())
self.verticalLayout.addWidget(self.multipleCheck)
self.verticalLayout.addWidget(QLabel(self.tr('Default value')))
self.defaultTextBox = QLineEdit()
self.defaultTextBox.setToolTip(
self.tr('Default field name, or ; separated list of field names for multiple field parameters'))
if self.param is not None:
default = self.param.defaultValue()
if default is not None:
self.defaultTextBox.setText(str(default))
self.verticalLayout.addWidget(self.defaultTextBox)
elif self.paramType == parameters.PARAMETER_BAND or \
isinstance(self.param, QgsProcessingParameterBand):
self.verticalLayout.addWidget(QLabel(self.tr('Parent layer')))
self.parentCombo = QComboBox()
idx = 0
for param in list(self.alg.parameterComponents().values()):
definition = self.alg.parameterDefinition(param.parameterName())
if isinstance(definition, (QgsProcessingParameterRasterLayer)):
self.parentCombo.addItem(definition.description(), definition.name())
if self.param is not None:
if self.param.parentLayerParameterName() == definition.name():
self.parentCombo.setCurrentIndex(idx)
idx += 1
#.........这里部分代码省略.........
示例5: initWidgets
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
def initWidgets(self):
# If there are advanced parameters — show corresponding groupbox
for param in self.alg.parameterDefinitions():
if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced:
self.grpAdvanced.show()
break
# Create widgets and put them in layouts
for param in self.alg.parameterDefinitions():
if param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
if param.isDestination():
continue
else:
desc = param.description()
if isinstance(param, QgsProcessingParameterExtent):
desc += self.tr(' (xmin, xmax, ymin, ymax)')
if isinstance(param, QgsProcessingParameterPoint):
desc += self.tr(' (x, y)')
if param.flags() & QgsProcessingParameterDefinition.FlagOptional:
desc += self.tr(' [optional]')
wrapper = WidgetWrapperFactory.create_wrapper(param, self.parent)
self.wrappers[param.name()] = wrapper
widget = wrapper.widget
if widget is not None:
if isinstance(param, QgsProcessingParameterFeatureSource):
layout = QHBoxLayout()
layout.setSpacing(2)
layout.setMargin(0)
layout.addWidget(widget)
button = QToolButton()
icon = QIcon(os.path.join(pluginPath, 'images', 'iterate.png'))
button.setIcon(icon)
button.setToolTip(self.tr('Iterate over this layer, creating a separate output for every feature in the layer'))
button.setCheckable(True)
layout.addWidget(button)
layout.setAlignment(button, Qt.AlignTop)
self.iterateButtons[param.name()] = button
button.toggled.connect(self.buttonToggled)
widget = QWidget()
widget.setLayout(layout)
widget.setToolTip(param.toolTip())
if type(widget) is QCheckBox:
# checkbox widget - so description is embedded in widget rather than a separate
# label
widget.setText(desc)
else:
label = QLabel(desc)
# label.setToolTip(tooltip)
self.labels[param.name()] = label
if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced:
self.layoutAdvanced.addWidget(label)
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, label)
if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced:
self.layoutAdvanced.addWidget(widget)
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, widget)
for output in self.alg.destinationParameterDefinitions():
if output.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
label = QLabel(output.description())
widget = DestinationSelectionPanel(output, self.alg)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
if isinstance(output, (QgsProcessingParameterRasterDestination, QgsProcessingParameterFeatureSink, QgsProcessingParameterVectorDestination)):
check = QCheckBox()
check.setText(self.tr('Open output file after running algorithm'))
check.setChecked(True)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, check)
self.checkBoxes[output.name()] = check
widget.setToolTip(param.toolTip())
self.outputWidgets[output.name()] = widget
for wrapper in list(self.wrappers.values()):
wrapper.postInitialize(list(self.wrappers.values()))
示例6: PythonConsoleWidget
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
#.........这里部分代码省略.........
self.layoutEditor.setMargin(0)
self.layoutEditor.setSpacing(0)
self.layoutEditor.addWidget(self.toolBarEditor, 0, 1, 1, 1)
self.layoutEditor.addWidget(self.widgetButtonEditor, 1, 0, 2, 1)
self.layoutEditor.addWidget(self.tabEditorWidget, 1, 1, 1, 1)
self.layoutEditor.addWidget(self.widgetFind, 2, 1, 1, 1)
# Layout for the find widget
self.layoutFind = QGridLayout(self.widgetFind)
self.layoutFind.setContentsMargins(0, 0, 0, 0)
self.lineEditFind = QgsFilterLineEdit()
placeHolderTxt = QCoreApplication.translate("PythonConsole", "Enter text to find…")
self.lineEditFind.setPlaceholderText(placeHolderTxt)
self.toolBarFindText = QToolBar()
self.toolBarFindText.setIconSize(icon_size)
self.findNextButton = QAction(self)
self.findNextButton.setEnabled(False)
toolTipfindNext = QCoreApplication.translate("PythonConsole", "Find Next")
self.findNextButton.setToolTip(toolTipfindNext)
self.findNextButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchNextEditorConsole.svg"))
self.findPrevButton = QAction(self)
self.findPrevButton.setEnabled(False)
toolTipfindPrev = QCoreApplication.translate("PythonConsole", "Find Previous")
self.findPrevButton.setToolTip(toolTipfindPrev)
self.findPrevButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchPrevEditorConsole.svg"))
self.caseSensitive = QCheckBox()
caseSensTr = QCoreApplication.translate("PythonConsole", "Case Sensitive")
self.caseSensitive.setText(caseSensTr)
self.wholeWord = QCheckBox()
wholeWordTr = QCoreApplication.translate("PythonConsole", "Whole Word")
self.wholeWord.setText(wholeWordTr)
self.wrapAround = QCheckBox()
self.wrapAround.setChecked(True)
wrapAroundTr = QCoreApplication.translate("PythonConsole", "Wrap Around")
self.wrapAround.setText(wrapAroundTr)
self.toolBarFindText.addWidget(self.lineEditFind)
self.toolBarFindText.addAction(self.findPrevButton)
self.toolBarFindText.addAction(self.findNextButton)
self.toolBarFindText.addWidget(self.caseSensitive)
self.toolBarFindText.addWidget(self.wholeWord)
self.toolBarFindText.addWidget(self.wrapAround)
self.layoutFind.addWidget(self.toolBarFindText, 0, 1, 1, 1)
# ------------ Add first Tab in Editor -------------------------------
# self.tabEditorWidget.newTabEditor(tabName='first', filename=None)
# ------------ Signal -------------------------------
self.findTextButton.triggered.connect(self._toggleFind)
self.objectListButton.toggled.connect(self.toggleObjectListWidget)
self.commentEditorButton.triggered.connect(self.commentCode)
self.uncommentEditorButton.triggered.connect(self.uncommentCode)
self.runScriptEditorButton.triggered.connect(self.runScriptEditor)
self.cutEditorButton.triggered.connect(self.cutEditor)
self.copyEditorButton.triggered.connect(self.copyEditor)
self.pasteEditorButton.triggered.connect(self.pasteEditor)
self.showEditorButton.toggled.connect(self.toggleEditor)
self.clearButton.triggered.connect(self.shellOut.clearConsole)
self.optionsButton.triggered.connect(self.openSettings)
self.runButton.triggered.connect(self.shell.entered)
self.openFileButton.triggered.connect(self.openScriptFile)
self.openInEditorButton.triggered.connect(self.openScriptFileExtEditor)
示例7: DialogOutputOptions
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [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()
示例8: initWidgets
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
def initWidgets(self):
# If there are advanced parameters — show corresponding groupbox
for param in self.alg.parameters:
if param.isAdvanced:
self.grpAdvanced.show()
break
# Create widgets and put them in layouts
for param in self.alg.parameters:
if param.hidden:
continue
desc = param.description
if isinstance(param, ParameterExtent):
desc += self.tr(' (xmin, xmax, ymin, ymax)')
if isinstance(param, ParameterPoint):
desc += self.tr(' (x, y)')
if param.optional:
desc += self.tr(' [optional]')
wrapper = self.getWidgetWrapperFromParameter(param)
self.wrappers[param.name] = wrapper
widget = wrapper.widget
if widget is not None:
if isinstance(param, ParameterVector):
layout = QHBoxLayout()
layout.setSpacing(2)
layout.setMargin(0)
layout.addWidget(widget)
button = QToolButton()
icon = QIcon(os.path.join(pluginPath, 'images', 'iterate.png'))
button.setIcon(icon)
button.setToolTip(self.tr('Iterate over this layer'))
button.setCheckable(True)
layout.addWidget(button)
self.iterateButtons[param.name] = button
button.toggled.connect(self.buttonToggled)
widget = QWidget()
widget.setLayout(layout)
tooltips = self.alg.getParameterDescriptions()
widget.setToolTip(tooltips.get(param.name, param.description))
if type(widget) is QCheckBox:
# checkbox widget - so description is embedded in widget rather than a separate
# label
widget.setText(desc)
else:
label = QLabel(desc)
# label.setToolTip(tooltip)
self.labels[param.name] = label
if param.isAdvanced:
self.layoutAdvanced.addWidget(label)
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, label)
if param.isAdvanced:
self.layoutAdvanced.addWidget(widget)
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, widget)
for output in self.alg.outputs:
if output.hidden:
continue
label = QLabel(output.description)
widget = OutputSelectionPanel(output, self.alg)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
if isinstance(output, (OutputRaster, OutputVector, OutputTable)):
check = QCheckBox()
check.setText(self.tr('Open output file after running algorithm'))
check.setChecked(True)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, check)
self.checkBoxes[output.name] = check
self.outputWidgets[output.name] = widget
for wrapper in list(self.wrappers.values()):
wrapper.postInitialize(list(self.wrappers.values()))
示例9: ModelerParameterDefinitionDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
class ModelerParameterDefinitionDialog(QDialog):
PARAMETER_NUMBER = 'Number'
PARAMETER_RASTER = 'Raster Layer'
PARAMETER_TABLE = 'Vector Layer'
PARAMETER_VECTOR = 'Vector Features'
PARAMETER_STRING = 'String'
PARAMETER_EXPRESSION = 'Expression'
PARAMETER_BOOLEAN = 'Boolean'
PARAMETER_TABLE_FIELD = 'Vector Field'
PARAMETER_EXTENT = 'Extent'
PARAMETER_FILE = 'File'
PARAMETER_POINT = 'Point'
PARAMETER_CRS = 'CRS'
PARAMETER_MULTIPLE = 'Multiple Input'
PARAMETER_BAND = 'Raster Band'
PARAMETER_MAP_LAYER = 'Map Layer'
paramTypes = [
PARAMETER_BOOLEAN,
PARAMETER_EXTENT,
PARAMETER_FILE,
PARAMETER_NUMBER,
PARAMETER_RASTER,
PARAMETER_STRING,
PARAMETER_EXPRESSION,
PARAMETER_MAP_LAYER,
PARAMETER_TABLE,
PARAMETER_TABLE_FIELD,
PARAMETER_VECTOR,
PARAMETER_POINT,
PARAMETER_CRS,
PARAMETER_MULTIPLE,
PARAMETER_BAND
]
def __init__(self, alg, paramType=None, param=None):
self.alg = alg
self.paramType = paramType
self.param = param
QDialog.__init__(self)
self.setModal(True)
self.setupUi()
settings = QgsSettings()
self.restoreGeometry(settings.value("/Processing/modelParametersDefinitionDialogGeometry", QByteArray()))
def closeEvent(self, event):
settings = QgsSettings()
settings.setValue("/Processing/modelParametersDefinitionDialogGeometry", self.saveGeometry())
super(ModelerParameterDefinitionDialog, self).closeEvent(event)
def setupUi(self):
self.setWindowTitle(self.tr('Parameter Definition'))
self.setMinimumWidth(300)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setMargin(20)
self.label = QLabel(self.tr('Parameter name'))
self.verticalLayout.addWidget(self.label)
self.nameTextBox = QLineEdit()
self.verticalLayout.addWidget(self.nameTextBox)
if isinstance(self.param, QgsProcessingParameterDefinition):
self.nameTextBox.setText(self.param.description())
if self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or \
isinstance(self.param, QgsProcessingParameterBoolean):
self.state = QCheckBox()
self.state.setText(self.tr('Checked'))
self.state.setChecked(False)
if self.param is not None:
self.state.setChecked(bool(self.param.defaultValue()))
self.verticalLayout.addWidget(self.state)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or \
isinstance(self.param, QgsProcessingParameterField):
self.verticalLayout.addWidget(QLabel(self.tr('Parent layer')))
self.parentCombo = QComboBox()
idx = 0
for param in list(self.alg.parameterComponents().values()):
definition = self.alg.parameterDefinition(param.parameterName())
if isinstance(definition, (QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer)):
self.parentCombo.addItem(definition.description(), definition.name())
if self.param is not None:
if self.param.parentLayerParameterName() == definition.name():
self.parentCombo.setCurrentIndex(idx)
idx += 1
self.verticalLayout.addWidget(self.parentCombo)
# add the datatype selector
self.verticalLayout.addWidget(QLabel(self.tr('Allowed data type')))
self.datatypeCombo = QComboBox()
self.datatypeCombo.addItem(self.tr('Any'), -1)
self.datatypeCombo.addItem(self.tr('Number'), 0)
self.datatypeCombo.addItem(self.tr('String'), 1)
self.datatypeCombo.addItem(self.tr('Date/time'), 2)
self.verticalLayout.addWidget(self.datatypeCombo)
if self.param is not None and self.param.dataType() is not None:
# QComboBoxes indexes start at 0,
# self.param.datatype start with -1 that is why I need to do +1
#.........这里部分代码省略.........
示例10: ModelerParameterDefinitionDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
class ModelerParameterDefinitionDialog(QDialog):
PARAMETER_NUMBER = 'Number'
PARAMETER_RASTER = 'Raster layer'
PARAMETER_TABLE = 'Table'
PARAMETER_VECTOR = 'Vector layer'
PARAMETER_STRING = 'String'
PARAMETER_BOOLEAN = 'Boolean'
PARAMETER_TABLE_FIELD = 'Table field'
PARAMETER_TABLE_MULTIPLE_FIELD = 'Table multiple field'
PARAMETER_EXTENT = 'Extent'
PARAMETER_FILE = 'File'
PARAMETER_POINT = 'Point'
# To add
PARAMETER_MULTIPLE = 'Multiple input'
PARAMETER_FIXED_TABLE = 'Fixed table'
paramTypes = [
PARAMETER_BOOLEAN,
PARAMETER_EXTENT,
PARAMETER_FILE,
PARAMETER_NUMBER,
PARAMETER_RASTER,
PARAMETER_STRING,
PARAMETER_TABLE,
PARAMETER_TABLE_FIELD,
PARAMETER_TABLE_MULTIPLE_FIELD,
PARAMETER_VECTOR,
PARAMETER_POINT
]
def __init__(self, alg, paramType=None, param=None):
self.alg = alg
self.paramType = paramType
self.param = param
QDialog.__init__(self)
self.setModal(True)
self.setupUi()
def setupUi(self):
self.setWindowTitle(self.tr('Parameter definition'))
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(40)
self.verticalLayout.setMargin(20)
self.horizontalLayoutName = QHBoxLayout(self)
self.horizontalLayoutName.setSpacing(2)
self.horizontalLayoutName.setMargin(0)
self.label = QLabel(self.tr('Parameter name'))
self.horizontalLayoutName.addWidget(self.label)
self.nameTextBox = QLineEdit()
self.horizontalLayoutName.addWidget(self.nameTextBox)
self.verticalLayout.addLayout(self.horizontalLayoutName)
self.horizontalLayoutRequired = QHBoxLayout(self)
self.horizontalLayoutRequired.setSpacing(2)
self.horizontalLayoutRequired.setMargin(0)
self.horizontalLayoutParent = QHBoxLayout(self)
self.horizontalLayoutParent.setSpacing(2)
self.horizontalLayoutParent.setMargin(0)
self.horizontalLayoutDefault = QHBoxLayout(self)
self.horizontalLayoutDefault.setSpacing(2)
self.horizontalLayoutDefault.setMargin(0)
self.horizontalLayoutDatatype = QHBoxLayout(self)
self.horizontalLayoutDatatype.setSpacing(2)
self.horizontalLayoutDatatype.setMargin(0)
if isinstance(self.param, Parameter):
self.nameTextBox.setText(self.param.description)
if self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or \
isinstance(self.param, ParameterBoolean):
self.state = QCheckBox()
self.state.setText(self.tr('Checked'))
self.state.setChecked(False)
if self.param is not None:
self.state.setChecked(True if self.param.value else False)
self.horizontalLayoutParent.addWidget(self.state)
self.verticalLayout.addLayout(self.horizontalLayoutParent)
elif self.paramType in (
ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD,
ModelerParameterDefinitionDialog.PARAMETER_TABLE_MULTIPLE_FIELD)\
or isinstance(self.param, (ParameterTableField,
ParameterTableMultipleField)):
self.horizontalLayoutParent.addWidget(QLabel(self.tr('Parent layer')))
self.parentCombo = QComboBox()
idx = 0
for param in self.alg.inputs.values():
if isinstance(param.param, (ParameterVector, ParameterTable)):
self.parentCombo.addItem(param.param.description, param.param.name)
if self.param is not None:
if self.param.parent == param.param.name:
self.parentCombo.setCurrentIndex(idx)
idx += 1
self.horizontalLayoutParent.addWidget(self.parentCombo)
self.verticalLayout.addLayout(self.horizontalLayoutParent)
# add the datatype selector
#.........这里部分代码省略.........
示例11: initWidgets
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
def initWidgets(self):
# If there are advanced parameters — show corresponding groupbox
for param in self.alg.parameters:
if param.isAdvanced:
self.grpAdvanced.show()
break
# Create widgets and put them in layouts
for param in self.alg.parameters:
if param.hidden:
continue
desc = param.description
if isinstance(param, ParameterExtent):
desc += self.tr(' (xmin, xmax, ymin, ymax)')
if isinstance(param, ParameterPoint):
desc += self.tr(' (x, y)')
try:
if param.optional:
desc += self.tr(' [optional]')
except:
pass
widget = self.getWidgetFromParameter(param)
self.valueItems[param.name] = widget
if isinstance(param, ParameterVector) and \
not self.alg.allowOnlyOpenedLayers:
layout = QHBoxLayout()
layout.setSpacing(2)
layout.setMargin(0)
layout.addWidget(widget)
button = QToolButton()
icon = QIcon(os.path.join(pluginPath, 'images', 'iterate.png'))
button.setIcon(icon)
button.setToolTip(self.tr('Iterate over this layer'))
button.setCheckable(True)
layout.addWidget(button)
self.iterateButtons[param.name] = button
button.toggled.connect(self.buttonToggled)
widget = QWidget()
widget.setLayout(layout)
tooltips = self.alg.getParameterDescriptions()
widget.setToolTip(tooltips.get(param.name, param.description))
if isinstance(param, ParameterBoolean):
widget.setText(desc)
if param.isAdvanced:
self.layoutAdvanced.addWidget(widget)
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, widget)
else:
label = QLabel(desc)
#label.setToolTip(tooltip)
self.labels[param.name] = label
if param.isAdvanced:
self.layoutAdvanced.addWidget(label)
self.layoutAdvanced.addWidget(widget)
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, label)
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, widget)
self.widgets[param.name] = widget
for output in self.alg.outputs:
if output.hidden:
continue
label = QLabel(output.description)
widget = OutputSelectionPanel(output, self.alg)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
if isinstance(output, (OutputRaster, OutputVector, OutputTable)):
check = QCheckBox()
check.setText(self.tr('Open output file after running algorithm'))
check.setChecked(True)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, check)
self.checkBoxes[output.name] = check
self.valueItems[output.name] = widget
if isinstance(output, OutputVector):
if output.base_input in self.dependentItems:
items = self.dependentItems[output.base_input]
else:
items = []
self.dependentItems[output.base_input] = items
items.append(output)
base_input = self.alg.getParameterFromName(output.base_input)
if isinstance(base_input, ParameterVector):
layers = dataobjects.getVectorLayers(base_input.shapetype)
else:
layers = dataobjects.getTables()
if len(layers) > 0:
output.base_layer = layers[0]
示例12: data
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
def data(self, profile_data):
"""Set data for the widget.
:param profile_data: profile data.
:type profile_data: dict
It will replace the previous data.
"""
default_profile = generate_default_profile()
self.clear()
for hazard in sorted(default_profile.keys()):
classifications = default_profile[hazard]
hazard_widget_item = QTreeWidgetItem()
hazard_widget_item.setData(0, Qt.UserRole, hazard)
hazard_widget_item.setText(0, get_name(hazard))
for classification in sorted(classifications.keys()):
# Filter out classification that doesn't support population.
# TODO(IS): This is not the best place to put the filtering.
# It's more suitable in the generate_default_profile method
# in safe/definitions/utilities.
classification_definition = definition(classification)
supported_exposures = classification_definition.get(
'exposures', [])
# Empty list means support all exposure
if supported_exposures != []:
if exposure_population not in supported_exposures:
continue
classes = classifications[classification]
classification_widget_item = QTreeWidgetItem()
classification_widget_item.setData(
0, Qt.UserRole, classification)
classification_widget_item.setText(0, get_name(classification))
hazard_widget_item.addChild(classification_widget_item)
for the_class, the_value in list(classes.items()):
the_class_widget_item = QTreeWidgetItem()
the_class_widget_item.setData(0, Qt.UserRole, the_class)
the_class_widget_item.setText(
0, get_class_name(the_class, classification))
classification_widget_item.addChild(the_class_widget_item)
# Adding widget must be happened after addChild
affected_check_box = QCheckBox(self)
# Set from profile_data if exist, else get default
profile_value = profile_data.get(
hazard, {}).get(classification, {}).get(
the_class, the_value)
affected_check_box.setChecked(profile_value['affected'])
self.setItemWidget(
the_class_widget_item, 1, affected_check_box)
displacement_rate_spinbox = PercentageSpinBox(self)
displacement_rate_spinbox.setValue(
profile_value['displacement_rate'])
displacement_rate_spinbox.setEnabled(
profile_value['affected'])
self.setItemWidget(
the_class_widget_item, 2, displacement_rate_spinbox)
# Behaviour when the check box is checked
# noinspection PyUnresolvedReferences
affected_check_box.stateChanged.connect(
displacement_rate_spinbox.setEnabled)
if hazard_widget_item.childCount() > 0:
self.widget_items.append(hazard_widget_item)
self.addTopLevelItems(self.widget_items)
self.expandAll()
示例13: Ui_form1
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import setChecked [as 别名]
class Ui_form1(object):
def setupUi(self, form1):
form1.setObjectName(_fromUtf8("form1"))
form1.resize(400, 253)
form1.setFocusPolicy(QtCore.Qt.TabFocus)
form1.setWindowTitle(_fromUtf8("Kuwahara filter"))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/qgis.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
form1.setWindowIcon(icon)
self.label = QLabel(form1)
self.label.setGeometry(QtCore.QRect(21, 10, 111, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label.setFont(font)
self.label.setToolTip(_fromUtf8(""))
self.label.setObjectName(_fromUtf8("label"))
self.outputb = QPushButton(form1)
self.outputb.setGeometry(QtCore.QRect(320, 47, 31, 23))
self.outputb.setObjectName(_fromUtf8("outputb"))
self.label_2 = QLabel(form1)
self.label_2.setGeometry(QtCore.QRect(22, 49, 101, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_2.setFont(font)
self.label_2.setToolTip(_fromUtf8(""))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.progressBar = QProgressBar(form1)
self.progressBar.setGeometry(QtCore.QRect(19, 220, 361, 23))
self.progressBar.setProperty(_fromUtf8("value"), 24)
self.progressBar.setObjectName(_fromUtf8("progressBar"))
self.label_3 = QLabel(form1)
self.label_3.setGeometry(QtCore.QRect(22, 88, 131, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_3.setFont(font)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QLabel(form1)
self.label_4.setGeometry(QtCore.QRect(21, 125, 181, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_4.setFont(font)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.run = QPushButton(form1)
self.run.setGeometry(QtCore.QRect(139, 185, 101, 23))
self.run.setObjectName(_fromUtf8("run"))
self.inputbox = QgsMapLayerComboBox(form1)
self.inputbox.setGeometry(QtCore.QRect(141, 10, 170, 22))
self.inputbox.setObjectName(_fromUtf8("input"))
self.output = QLineEdit(form1)
self.output.setGeometry(QtCore.QRect(149, 45, 160, 28))
self.output.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.output.setObjectName(_fromUtf8("output"))
self.refb = QLineEdit(form1)
self.refb.setGeometry(QtCore.QRect(149, 82, 160, 28))
self.refb.setObjectName(_fromUtf8("refb"))
self.mem = QLineEdit(form1)
self.mem.setGeometry(QtCore.QRect(208, 120, 101, 28))
self.mem.setObjectName(_fromUtf8("mem"))
self.addout = QCheckBox(form1)
self.addout.setGeometry(QtCore.QRect(100, 158, 171, 17))
self.addout.setChecked(True)
self.addout.setObjectName(_fromUtf8("checkBox"))
self.inputb = QPushButton(form1)
self.inputb.setGeometry(QtCore.QRect(320, 10, 31, 23))
self.inputb.setObjectName(_fromUtf8("inputb"))
self.retranslateUi(form1)
self.setWindowFlags(QtCore.Qt.WindowFlags(QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint))
QtCore.QMetaObject.connectSlotsByName(form1)
def retranslateUi(self, form1):
self.label.setText(QtCore.QCoreApplication.translate("form1", "Input raster"))
self.outputb.setText("...")
self.label_2.setText(QApplication.translate("form1", "Output raster"))
self.label_3.setToolTip(QApplication.translate("form1", "Reference band from which variances will be calculated to choose subwindow mean."))
self.label_3.setText(QApplication.translate("form1", "Reference band"))
self.label_4.setToolTip(QApplication.translate("form1", "Maximum memory usage in megabytes (it is an approximated value, since algorithm will only choose how many lines will be read at once)."))
self.label_4.setText(QApplication.translate("form1", "Max memory usage (MB)"))
self.run.setText(QApplication.translate("form1", "Run"))
self.output.setPlaceholderText(QApplication.translate("form1", "<temporary file>"))
self.refb.setToolTip(QApplication.translate("form1", "Reference band from which variances will be calculated to choose subwindow mean."))
self.refb.setText("1")
self.mem.setToolTip(QApplication.translate("form1", "Maximum memory usage in MeB (it is an approximated value, since algorithm will only choose how many lines will be read at once)."))
self.mem.setText("100")
self.addout.setText(QApplication.translate("form1", "Add results to project"))
self.inputb.setText("...")