Как бы ето окно уничтожать после использования?
from tkFileDialog import askopenfilename
fl = askopenfilename()
print fl
while 1:
pass #тут оно уже не надо
from tkFileDialog import askopenfilename
fl = askopenfilename()
print fl
while 1:
pass #тут оно уже не надо
>>> from tkinter import *
>>> import tkinter.messagebox as mbox
>>> i_do_not_wanna_die = False
>>> class Ask(Frame):
def __init__(self, master=None, callback=None):
Frame.__init__(self, master)
self.grid()
global i_do_not_wanna_die
i_do_not_wanna_die = mbox.askyesno("Hmmm...",
"Are you give me a dollar?")
self.winfo_toplevel().destroy()
>>> def test():
App = Ask()
App.mainloop()
for i in range(10):
if i_do_not_wanna_die:
print("You can live :).")
else:
print("You don't deserve even a death!")
>>> test()
You don't deserve even a death!
You don't deserve even a death!
You don't deserve even a death!
You don't deserve even a death!
You don't deserve even a death!
You don't deserve even a death!
You don't deserve even a death!
You don't deserve even a death!
You don't deserve even a death!
You don't deserve even a death!