[英]qgis plugin using python
我正在嘗試使用最新版本的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功能正常工作
該錯誤消息清楚地表明您做錯了什么: AttributeError: AutomatisationDEPLOIEMENT instance has no attribute 'utilisat_lineEdit'
在loginCheck()
的第一行中,您嘗試訪問self.utilisat_lineEdit
但是此屬性不存在。 我猜您正在嘗試訪問某種gui元素,但這在您的課程中不可用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.