Tkinter退出错误

时间:2016-11-11 22:11:48

标签: python tkinter

我一直试图让代码正确,但不知何故它出错了。 我的代码如下:

from Tkinter import *
import time

def show():
    p=password.get()
    o=open('C:\Working\Documents\Aditya\Write To.txt', "w+")
    o.write(p)
    o.close()
    time.sleep(2)
    app.exit()

app = Tk()
password = StringVar() #Password variable
passEntry = Entry(app, textvariable=password, show='*', width="40").pack()
submit = Button(app, text='OK',command=show, width="20")
submit.pack()
app.geometry("400x400")


app.mainloop()

我得到的错误是:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "C:\Working\Documents\Aditya\Password.py", line 10, in show
app.exit()
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1722, in __getattr__
return getattr(self.tk, attr)
AttributeError: exit

如果你能帮助我。

0 个答案:

没有答案