lundi 28 décembre 2020

How do I add a command (tkinter) in an if statement?

I have created an if statement to check if the username and password and username entered is the same to the username and password in the textile. I have been able to display if the data inputted is correct or not. I now want to add a command into the if statement e.g. command = main_menu if the data inputted is correct (I am using tkinter)

This is the if code I have so far:

def validation(username1, password1):
    file = open("Accounts.txt", "r")
    for line in file:
        line = line.split("\n")
        line = line[0].split(" ")

        if username1 == line[0] and password1 == line[1]:
            valid = Label(root, text="Data: Found")
            valid.place(x=290, y=130)
        else:
            valid = Label(root, text="Data: Not found")
            valid.place(x=280, y=130)

    file.close()

Any ideas on how to do this?

Thanks xx

Aucun commentaire:

Enregistrer un commentaire