Suppose I have one GUI with a simple code as follows It has a button on it and when this is clicked I want to have another GUI to pop-up and then call the function from it. The problem is that when I run the first file, the GUI of the other one automatically pop-up. What should I do.
The code of the first file is as follows
from tkinter import *
import another
root = Tk()
button1 = Button(root, text = "Call" , command = another.abc)
button1.pack()
root.mainloop()
The code of second file another.py is as follows
from tkinter import *
root_Test2 = Tk()
root_Test2.geometry('450x450')
def abc():
print("that's working")
root_Test2.mainloop()
Please suggest the solution that help me to open the second window when the button on the first one is clicked
mainloopthat shouldn't get run, theroot_Test2 = Tk()androot_Test2.geometry('450x450')shouldn't get run either. Only the Tkinter import and theabcfunction definition can get executed. The other stuff must be protected inside aif __name__ == "__main__":block.