Ok so I'm trying to make a inter face with a password. my plan is to have a window open up with an input box where you type the password and then when you have the right password it brings you to the second screen with the stuff on it. right now my log in screen doesnt have a working password I've tryed everything as well. only thing working on it is the shutdown button at the bottom. The password is _____ and then you hit enter/return key to enter or atlest thats what i want i dont want a button.
here is my code any help would be greatful for i'm working on a importing school project and dont have a clue how to get it working. I maked the area with a hash tag #
from tkinter import *
import tkinter as tk
# Create the window
##t = Tk()
root = Tk()
root.title("NEOSA Corp Interface")
# Background
p = PhotoImage(file="CIA.gif")
l = Label(root, image=p)
# Password for main screen
e = Entry(l, show="*", width=30)
e.pack(side=TOP, anchor=W, padx=450, pady=300)
e.focus()
######################################################
# Fail entery
def make_entry(parent, caption, width=None, **options):
tk.Label(parent, text=caption).pack(side=tk.TOP)
entry = tk.Entry(parent, **options)
if width:
entry.config(width=width)
entry.pack(side=tk.TOP, padx=10, fill=tk.BOTH)
return entry
def enter(event):
check_password()
def check_password(failures=[]):
""" Collect 1's for every failure and quit program in case of failure_max failures """
print(user.get(), password.get())
if (user.get(), password.get()) in passwords:
root.destroy()
print('Logged in')
return
failures.append(1)
if sum(failures) >= failure_max:
root.destroy()
raise SystemExit('Unauthorized login attempt')
else:
root.title('Try again. Attempt %i/%i' % (sum(failures)+1, failure_max))
#frame for window margin
parent = tk.Frame(root, padx=10, pady=10)
parent.pack(fill=tk.BOTH, expand=True)
#entrys with not shown text
user = make_entry(parent, "User name:", 16, show='')
password = make_entry(parent, "Password:", 16, show="*")
#button to attempt to login
b = tk.Button(parent, borderwidth=4, text="Login", width=10, pady=8, command=check_password)
b.pack(side=tk.BOTTOM)
password.bind('<Return>', enter)
user.focus_set()
###########################################################################
# Main Screen Shut Down
b = Button(l, command=quit, text="Shut Down")
b.pack(side=BOTTOM, expand=Y, anchor=S)
l.pack_propagate(0)
l.pack()
root.mainloop()
root = Tk()
# Modify root window
root.title("NEOSA Corp Interface")
root.geometry("1024x768")
# Kick off the event loop
root.mainloop()