我需要一个包含登录详细信息的变量,我的所有类都在单独的文件中。
第一个类是登录窗口,它将从数据库中获取用户名和密码
LoginBtn.clicked.connect(self.CheckLogin)
def CheckLogin(self):
self.username = self.usernameLE.text()
self.password = self.passwordLE.text()
with sqlite3.connect("Accounts.db") as db:
cursor = db.cursor()
cursor.execute("SELECT * FROM Accounts WHERE Username=? ",(self.username,))
self.account = cursor.fetchone()
try:
if self.account[0] == self.username and self.account[1] == self.password:
if self.account[2] == 'Admin':
self.OpenSystem = CurrentLayoutAdmin()
self.OpenSystem.show()
self.hide()
elif self.account[2] == 'Manager':
self.departmentsave = self.account[2]
self.OpenManagerSystem = CurrentLayoutManager() #This goes to main menu and once a button is clicked it opens up another window. The one I need the variable for.
self.OpenManagerSystem.show()
self.hide()
else:
pass
else:
self.invalid_lbl.setVisible(True)
self.passwordLE.setText('')
except TypeError:
self.invalid_lbl.setVisible(True)
self.passwordLE.setText('')
我需要持有部门的self.account[2]
。
def CreateTable(self):
accountdetails = LoginWindow()
accountdetails.CheckLogin()
print(accountdetails.departmentsave)
我无法弄清楚如何调用此变量。