store function attribute of class in QGIS plugin

المشرف العام

Administrator
طاقم الإدارة
I'm pretty new to python and pyqgis so the question will be pretty trivial..

I'm writing a plugin and in one script I have a class and some internal functions..

....class CreateModelDialog(QDialog, FORM_CLASS): def __init__(self, iface): QDialog.__init__(self).... def openSr(self): projSelector = QgsGenericProjectionSelector() projSelector.exec_() self.srText.setText(projSelector.selectedAuthId())Then I have to use the last line (that is the EPSG cose selected and displayed in srText QLineEdit of the QT dialog in another function of the same script:

def createModel(self): modelName = self.bxDBname.text() modelType = self.cmbBxModelType.currentText() crs = self.srText.setText(projSelector.selectedAuthId())createModel(modelName, modelType, crs)But I get an error:

NameError: global name 'projSelector' is not definedI'm sure that is due to the fact that projSelector is a variable that exists only in the local open Sr function.

So the question is: how should I modify the function in order to make the variable callable?

Thanks!



أكثر...
 
أعلى