oliver
Posts: 26
Joined: Sun Mar 30, 2014 4:53 pm

tkinter extra window

Mon Nov 03, 2014 10:23 am

Hi
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 :( why would this be and is there a way to stop it happening as i would like a bug free software i could run over VNC on a IPad or laptop.

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()



thanks in advance,
Olly

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: tkinter extra window

Mon Nov 03, 2014 12:06 pm

Locking topic - please do not double post your questions.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Return to “Troubleshooting”