Reputation: 1277
Imagine the following very simple example:
from tkinter import *
from tempFunctions import *
startingWin = Tk()
button = Button(startingWin, text="Open Other Win", command=lambda: openSecondWin()).grid(row=0, column=0, padx=30, pady=30)
startingWin.mainloop()
The output is simply as following:
No if I click on the button, I open the second Win like:
The second window has the following code in tempFunctions.py:
from tkinter import *
def openSecondWin():
secondWin = Tk()
cancelButton = Button(secondWin, text="Cancel", command=secondWin.quit).grid(row=0, column=0, padx=30, pady=30)
secondWin.mainloop()
I expect that when I press cancel, the secondWin should close. That doesn't happen. What I get is that when I click cancel, the second Win doesn't close. However, if click twice both windows (startingWin and secondWin) close together. Why?
Is there a logical explanation for this? Thanks!
Trying with binding results in the same problem.
Also making the second win as Toplevel doesn't help.
Upvotes: 0
Views: 536