本文整理匯總了Python中qgis.gui.QgsMapLayerComboBox.currentText方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsMapLayerComboBox.currentText方法的具體用法?Python QgsMapLayerComboBox.currentText怎麽用?Python QgsMapLayerComboBox.currentText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis.gui.QgsMapLayerComboBox
的用法示例。
在下文中一共展示了QgsMapLayerComboBox.currentText方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Dialog
# 需要導入模塊: from qgis.gui import QgsMapLayerComboBox [as 別名]
# 或者: from qgis.gui.QgsMapLayerComboBox import currentText [as 別名]
class Dialog(QtGui.QDialog):
def __init__(self, curPointLayerName, curPolygonLayerName, curFiledName, parent=None):
QtGui.QDialog.__init__(self, parent)
self.resize(300, 100)
Plugin().plPrint("curPointLayerName:: %s" % curPointLayerName)
Plugin().plPrint("curPolygonLayerName:: %s" % curPolygonLayerName)
Plugin().plPrint("curFiledName:: %s" % curFiledName)
self.setWindowTitle(Plugin().getPluginName())
self.__mainLayout = QtGui.QVBoxLayout(self)
self.__layout = QtGui.QGridLayout(self)
# self.__layout.addWidget(QtGui.QLabel(self.tr("Point layer name") + ":"), 0, 0)
l1 = QtGui.QLabel(u"Имя точечного слоя" + ":")
l1.setSizePolicy(
QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.Fixed
)
self.__layout.addWidget(l1, 0, 0)
self.pointsLayersComboBox = QgsMapLayerComboBox()
self.pointsLayersComboBox.setSizePolicy(
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Fixed
)
self.pointsLayersComboBox.setFilters(QgsMapLayerProxyModel.PointLayer)
self.pointsLayersComboBox.setEditable(True)
self.pointsLayersComboBox.setEditText(curPointLayerName)
self.pointsLayersComboBox.layerChanged.connect(self.layerChooze1)
self.__layout.addWidget(self.pointsLayersComboBox, 0, 1)
# self.__layout.addWidget(QtGui.QLabel(self.tr("Field name") + ":"), 2, 0)
self.__layout.addWidget(QtGui.QLabel(u"Имя поля" + ":"), 2, 0)
self.fieldName = QgsFieldComboBox()
self.fieldName.setFilters(QgsFieldProxyModel.Int)
self.fieldName.setEditable(True)
self.fieldName.setEditText(curFiledName)
self.fieldName.fieldChanged.connect(self.filedChooze)
self.__layout.addWidget(self.fieldName, 2, 1)
# self.__layout.addWidget(QtGui.QLabel(self.tr("Polypon layer name") + ":"), 1, 0)
self.__layout.addWidget(QtGui.QLabel(u"Имя полигонального слоя" + ":"), 1, 0)
self.polygonsLayersComboBox = QgsMapLayerComboBox()
self.polygonsLayersComboBox.setFilters(QgsMapLayerProxyModel.PolygonLayer)
self.polygonsLayersComboBox.setEditable(True)
self.polygonsLayersComboBox.setEditText(curPolygonLayerName)
self.polygonsLayersComboBox.layerChanged.connect(self.layerChooze2)
self.polygonsLayersComboBox.layerChanged.connect(self.fieldName.setLayer)
self.__layout.addWidget(self.polygonsLayersComboBox, 1, 1)
# self.startButton = QtGui.QPushButton(self.tr("Start"))
# self.startButton.clicked.connect(self.startCalculation)
# self.__layout.addWidget(self.startButton, 3, 1)
self.__mainLayout.addLayout(self.__layout)
# self.progress = QtGui.QLabel()
# self.__mainLayout.addWidget(self.progress)
self.__bbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
self.__bbox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
self.__bbox.accepted.connect(self.accept)
self.__mainLayout.addWidget(self.__bbox)
def layerChooze1(self, qgsMapLayer):
self.pointsLayersComboBox.setEditText(qgsMapLayer.name())
def layerChooze2(self, qgsMapLayer):
self.polygonsLayersComboBox.setEditText(qgsMapLayer.name())
def filedChooze(self, fieldName):
self.sender().setEditText(fieldName)
# def layernameSave(self, csTargetLayerName):
# if csTargetLayerName == u"":
# return
# setCSLayerName(csTargetLayerName)
def getSettings(self):
return [
self.pointsLayersComboBox.currentText(),
self.polygonsLayersComboBox.currentText(),
self.fieldName.currentText()
]
示例2: Dialog
# 需要導入模塊: from qgis.gui import QgsMapLayerComboBox [as 別名]
# 或者: from qgis.gui.QgsMapLayerComboBox import currentText [as 別名]
#.........這裏部分代碼省略.........
def fillControls(
self,
curPointsLayerFrom,
curPointsLayerTo,
curFNIdFrom,
curFNLink,
curFNIdTo,
curResultLayerName
):
QgisPlugin().plPrint("curPointsLayerFrom: " + curPointsLayerFrom)
QgisPlugin().plPrint("curPointsLayerTo: " + curPointsLayerTo)
QgisPlugin().plPrint("curFNIdFrom: " + curPointsLayerFrom)
QgisPlugin().plPrint("curFNLink: " + curFNIdFrom)
QgisPlugin().plPrint("curPointsLayerFrom: " + curFNLink)
QgisPlugin().plPrint("curFNIdTo: " + curFNIdTo)
QgisPlugin().plPrint("curResultLayerName: " + curResultLayerName)
layerFrom = self.getQGISLayer(curPointsLayerFrom)
layerTo = self.getQGISLayer(curPointsLayerTo)
layerResult = self.getQGISLayer(curResultLayerName, True)
if layerFrom is None:
self.pointsLayerFrom.setCurrentIndex(-1)
self.pointsLayerFrom.setEditText(curPointsLayerFrom)
else:
self.pointsLayerFrom.setLayer(layerFrom)
if layerTo is None:
self.pointsLayerTo.setCurrentIndex(-1)
self.pointsLayerTo.setEditText(curPointsLayerTo)
else:
self.pointsLayerTo.setLayer(layerTo)
if layerResult is None:
self.linesLayer.setCurrentIndex(-1)
self.linesLayer.setEditText(curResultLayerName)
else:
self.linesLayer.setLayer(layerResult)
# self.fnIdFrom.clear()
# self.fnLink.clear()
# self.fnIdTo.clear()
# self.fnIdFrom.setField(curFNIdFrom)
self.fnIdFrom.setCurrentIndex(-1)
self.fnIdFrom.setEditText(curFNIdFrom)
# self.fnLink.setField(curFNLink)
self.fnLink.setCurrentIndex(-1)
self.fnLink.setEditText(curFNLink)
# self.fnIdTo.setField(curFNIdTo)
self.fnIdTo.setCurrentIndex(-1)
self.fnIdTo.setEditText(curFNIdTo)
def getQGISLayer(self, layerName, silent=False):
if layerName is None:
return
if layerName == "":
return
layers = QgsMapLayerRegistry.instance().mapLayersByName(layerName)
if len(layers) == 0:
if silent is False:
QgisPlugin().showMessageForUser(
self.tr(u"Layer with name '%s' not found!") % layerName,
QgsMessageBar.CRITICAL,
0
)
return None
return layers[0]
def choozeLayerFrom(self, qgsMapLayer):
self.pointsLayerFrom.setEditText(qgsMapLayer.name())
def choozeLayerTo(self, qgsMapLayer):
self.pointsLayerTo.setEditText(qgsMapLayer.name())
def choozeResultLayer(self, qgsMapLayer):
self.linesLayer.setEditText(qgsMapLayer.name())
def filedChooze(self, fieldName):
self.sender().setEditText(fieldName)
def chooseResultFilename(self):
filename = QtGui.QFileDialog.getSaveFileName(
self,
self.tr(u"Choose file for save result"),
self.curResultFilename
# QtCore.QFileInfo(self.curResultFilename).absolutePath()
)
self.leResultFilename.setText(filename)
def getSettings(self):
return [
self.pointsLayerFrom.currentText(),
self.pointsLayerTo.currentText(),
self.fnIdFrom.currentText(),
self.fnLink.currentText(),
self.fnIdTo.currentText(),
self.linesLayer.currentText(),
]