我正在尝试使用最新版本的python和qgis 2.18对qgis插件进行编码,但我一直收到以下错误消息:
AttributeError: AutomatisationDEPLOIEMENT instance has no attribute 'utilisat_lineEdit'
这是我的代码,有人可以帮助我吗?
class AutomatisationDEPLOIEMENT:
"""QGIS Plugin Implementation."""
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgisInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'AutomatisationDEPLOIEMENT_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&Automatisation DEPLOIEMENT')
# TODO: We are going to let the user set this up in a future iteration
self.toolbar = self.iface.addToolBar(u'AutomatisationDEPLOIEMENT')
self.toolbar.setObjectName(u'AutomatisationDEPLOIEMENT')
...片段...
def loginCheck(self):
username = self.utilisat_lineEdit.text()
password = self.pass_lineEdit.text()
connection = sqlite3.connect("login.db")
result = connection.execute("SELECT * FROM USERS WHERE USERNAME = ? AND PASSWORD = ?", (username, password))
if (len(result.fetchall()) > 0):
print("User Found ! ")
else:
print("User Not Found !")
self.showMessageBox('Warning', 'Invalid Username And Password')
connection.close()
我正在尝试使logincheck功能正常工作
答案 0 :(得分:1)
错误消息清楚地表明您做错了什么:
AttributeError: AutomatisationDEPLOIEMENT instance has no attribute 'utilisat_lineEdit'
在loginCheck()
的第一行中,您尝试访问self.utilisat_lineEdit
,但该属性不存在。我猜您正在尝试访问某种gui元素,但这在您的课程中不可用。