Problems with import stament when using tkinter Problems with import stament when using tkinter tkinter tkinter

Problems with import stament when using tkinter


This happens because when you import python files, you are essentially running the entire file to get a reference. When file1 runs in its entirety, the entire file is interpreted and ran. This includes the last line, root.mainloop()

What you want to use is the best practice of having a check for if the current file is the main file. This will prevent it from running certain lines of code if it is not the current, main program.

You're looking for something like this:

if __name__ == "__main__":    root.mainloop()