I have something like this:
first.py
from tkinter import *
def new_window(event):
root.destroy()
import second
root = Tk()
b = Button(root, text='New window')
b.pack()
b.bind('<Button-1>', new_window)
root.mainloop()
second.py
from tkinter import *
root = Tk()
root.mainloop()
But when I open the second window, the first one is destroyed (I hope so), but the second one is frozen (it is shown, but there is no close-button on the top and I only see the launch-icon). Why is it so? Don't I kill the first loop?
The problem is likely because import second
never returns since the last thing it does is call root.mainloop()
. Since it never returns, the callback in the first window never finishes. And since it never finishes, it's not able to process any other events.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.