Me and my friend are making a program that requires a login at the start. We've managed to get the user to input details, and have the program create a text file called (users name) profile with the details in. each one is formatted like this:
(Name)
(Username)
(Password)
when you want to log in, the program asks for your name and finds the file with the name (whatever they typed) profile. if it exists, the program then opens a GUI window and asks for the username and password, and if you put in the correct details for the file it has opened, it says that the details are wrong. We think its to do with the variables, but we've tried lot of different ways of laying it out e.t.c and can't find the problem. Can anyone help? (The code I have included is only the GUI part including the bit that isn't working, the rest is fine.
# Log in
def LogIn():
name=input("Please enter your name: ")
file = open(name.lower() + " profile.txt", "r")
#+=========GUI===========GUI============GUI===========+
#mport modules
import tkinter
import time
#---Window---#
#make window
window = tkinter.Tk()
#change title
window.title("Python Games Login")
#change size
window.geometry("270x210")
#change window icon
window.wm_iconbitmap("Login icon.ico")
#change window colour
window.configure(bg="#39d972")
#---Commands---#
#go
def callback():
line = file.readlines()
username = user.get()
password = passw.get()
if username == line[1] and password == line[2]:
message.configure(text = "Logged in.")
else:
message.configure(text = "Username and password don't match the account \n under the name;\n \'" + name + "\'. \nPlease try again.")
#---Widgets---#
#labels
title1 = tkinter.Label(window, text="--Log in to play the Python Games--\n", bg="#39d972")
usertitle = tkinter.Label(window, text="---Username---", bg="#39d972")
passtitle = tkinter.Label(window, text="---Password---", bg="#39d972")
message = tkinter.Label(window, bg="#39d972")
#text entry windows
user = tkinter.Entry(window)
passw = tkinter.Entry(window, show='*')
#buttons
go = tkinter.Button(window, text="Log in!", command = callback, bg="#93ff00")
#pack widgets
title1.pack()
usertitle.pack()
user.pack()
passtitle.pack()
passw.pack()
go.pack()
message.pack()
#start window
window.mainloop()
#+===================GUI END=====================+