使用python的qgis插件

2024-10-01 22:41:24 发布

您现在位置: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功能正常工作


Tags: thetopathinstanceselfifosconnection
1条回答
网友
1楼 · 发布于 2024-10-01 22:41:24

错误消息清楚地显示了您做错了什么: AttributeError: AutomatisationDEPLOIEMENT instance has no attribute 'utilisat_lineEdit'

loginCheck()的第一行中,您试图访问self.utilisat_lineEdit,但此属性不存在。我猜您正在尝试访问某种gui元素,但这在您的类中不可用。你知道吗

相关问题 更多 >

    热门问题