本文整理汇总了Python中qgis.PyQt.QtWidgets.QCheckBox.checkState方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.checkState方法的具体用法?Python QCheckBox.checkState怎么用?Python QCheckBox.checkState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QCheckBox
的用法示例。
在下文中一共展示了QCheckBox.checkState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QDrawLayerDialog
# 需要导入模块: from qgis.PyQt.QtWidgets import QCheckBox [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QCheckBox import checkState [as 别名]
class QDrawLayerDialog(QDialog):
def __init__(self, iface, gtype):
QDialog.__init__(self)
self.setWindowTitle(self.tr('Drawing'))
self.name = QLineEdit()
if gtype == 'point' or gtype == 'XYpoint':
gtype = 'Point'
elif gtype == 'line':
gtype = 'LineString'
else:
gtype = 'Polygon'
# change here by QgsMapLayerComboBox()
self.layerBox = QComboBox()
self.layers = []
for layer in QgsProject.instance().mapLayers().values():
if layer.providerType() == "memory":
# ligne suivante à remplacer par if layer.geometryType() == :
if gtype in layer.dataProvider().dataSourceUri()[:26]: # must be of the same type of the draw
if 'field='+self.tr('Drawings')+':string(255,0)' in layer.dataProvider().dataSourceUri()[-28:]: # must have its first field named Drawings, string type
self.layers.append(layer)
self.layerBox.addItem(layer.name())
self.addLayer = QCheckBox(self.tr('Add to an existing layer'))
self.addLayer.toggled.connect(self.addLayerChecked)
buttons = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject)
vbox = QVBoxLayout()
vbox.addWidget(QLabel(self.tr("Give a name to the feature:")))
vbox.addWidget(self.name)
vbox.addWidget(self.addLayer)
vbox.addWidget(self.layerBox)
if len(self.layers) == 0:
self.addLayer.setEnabled(False)
self.layerBox.setEnabled(False)
vbox.addWidget(buttons)
self.setLayout(vbox)
self.layerBox.setEnabled(False)
self.name.setFocus()
def tr(self, message):
return QCoreApplication.translate('Qdraw', message)
def addLayerChecked(self):
if self.addLayer.checkState() == Qt.Checked:
self.layerBox.setEnabled(True)
else:
self.layerBox.setEnabled(False)
def getName(self, iface, gtype):
dialog = QDrawLayerDialog(iface, gtype)
result = dialog.exec_()
return (
dialog.name.text(),
dialog.addLayer.checkState() == Qt.Checked,
dialog.layerBox.currentIndex(),
dialog.layers,
result == QDialog.Accepted)