繁体   English   中英

使用python的qgis插件

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM