In tkinter i have have written a code which creates a login page for my robot controller application but it comes up with an extra window named tk #2. I get my normal login window and then when i login it opens my robot controller application and closes the login page but the other tk #2 window is still there
Code: Select all
from Tkinter import *
def login():
if u.get() == 'p' and p.get() == 'p':
print 'your logged in'
root = Tk()
root.title('Robot Controller')
top.destroy()
root.mainloop()
else:
passwordincorrect = Label(root, text='Password incorrect please try again', bg='yellow', fg='red')
passwordincorrect.pack()
#create window
top=Toplevel()
top.title('Login')
top.configure(background='yellow')
#make the username label
username = Label(top, text='Username:', bg='yellow')
username.pack()
#make the username entry widget
u = Entry(top)
u.pack()
#make the password label
password = Label(top, text='Password:', bg='yellow')
password.pack()
#make the password entry widget
p = Entry(top)
p.pack()
#make the login button
login = Button(top, text='Login:', command=login, fg='white', bg='red')
login.pack()
top.mainloop()
Olly
