1

I wanted to test out a few things in Python and write a script in which you can log in with your name and password. I have setup a GUI using Tkinter in which you are asked to enter your name and password and I have a function (login_check()) that tests if your password is correct but I don't know how to constantly run login_check() while displaying the GUI (root). That's my code so far:

from Tkinter import *

def login_check():
name = entry_name.get()
password = entry_password.get()
if name == "Marvin":
    if password == "123":
        print("You are now logged in")
    else:
        print("wrong password.")
else:
    print("This username does not exist.")


root = Tk()

label_name = Label(root, text="Name")
label_password = Label(root, text="Password")
entry_name = Entry(root)
entry_password = Entry(root)

label_name.grid(row=0, sticky=E)
label_password.grid(row=1, sticky=E)
entry_name.grid(row=0, column=1)
entry_password.grid(row=1, column=1)


login_check()
root.mainloop()
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.