私がやっている授業プロジェクトの一環として、ログインページを作成してデータベースを組み込む必要があります。私はdoeを普通の形で使っていますが、これをtkinterを使ってGUIに入れ、それを動作させるために私はデータベース内のレコードを呼び出すページ上の関数を使用しなければなりませんでした。私が経験している問題は、この関数を呼び出すと、何もしません。おそらく、コーディングの単純な間違いが原因ですが、なんらかの理由でそれを理解できません。クラスを機能させることができません
class LogInScreen(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
description = tk.Label(self, text="Please log in to gain access to the content of this computer science program.", font=LARGE_FONT)
description.pack()
label1 = tk.Label(self, text="Enter your username:")
label1.pack()
self.usernameEntry = tk.Entry(self)
self.usernameEntry.pack()
label2 = tk.Label(self, text="Enter your password:")
label2.pack()
self.passwordEntry = tk.Entry(self, show="*")
self.passwordEntry.pack()
notRecognised=tk.Label(self, text="")
logInButton = tk.Button(self, text="Log In", command=lambda: self.logUserIn)
logInButton.pack()
self.controller = controller
button1 = tk.Button(self, text="Back to Home",
command=lambda: controller.show_frame(SplashScreen))
button1.pack()
button2 = tk.Button(self, text="Sign Up",
command=lambda: controller.show_frame(SignUpScreen))
button2.pack()
def logUserIn():
username = self.usernameEntry.get()
password = self.passwordEntry.get()
find_user = ("SELECT * FROM user WHERE username == ? AND password == ?")
cursor.execute(find_user,[(username),(password)])
results = cursor.fetchall()
if results:
controller.show_frame(HubScreen)
else:
loginResult = tk.Label(self, text="Account credentials not recognised, please try again")
loginResult.pack()
私は仕事と本当にここの人々は、提供することができる助けを必要とするために、この機能を取得して行くべきかに関してはわかりませんよ。私はコードを見て余りにも長い時間を費やし、それを続行するために何もしませんでした。プログラムの他の部分をやっていましたが、この機能を使わないと評価するのは難しいです。私の才能よりも才能のある人たちに不便をおかけして申し訳ありませんが、その学習プロセスと私は私が行くにつれて改善しようとしています。この行で
'self'を渡してください:def logUserIn(self):' –
あなたはどうしていますか? – mnistic
なぜログイン画面にクラスを使用していますか? – mrCarnivore