Multiple Windows in Tkinter

Hello! Please help to resolve the issue in my Tkinter code…

Problem Statement:
I have a simple tkinter logIn page that contains a login button. On clicking this button, I want to close this login page and wants to open (or run) a new python file that displays main project GUI (that contains many tkinter widgets buttons, text boxes, labels etc.). Further, on this main GUI, I have a “Back to Login Window” Button. When i click this button then I want to close this main GUI page and wants to display again Login page. Upto this stage, my code do as i want (code is working as i desires).

BUT,after this when I again, Press login button to close it and open main GUI but not successfull…my main GUI page closes but this does not open main GUI page again…why it so? please help me.

(1) I have made a small project with two python files, with names and the other is

(2) Code of is as:

`from tkinter import *

def login():
import mainGUI

logInWindow = Tk()
logInWindow.title(“Login Window Title”)

logInButton = Button(logInWindow, text=“Login”, width=15, font=(‘times new roman’, 15, ‘bold’), bd=2, command=login),y=250)



(3) Code of is as:
`from tkinter import *

def backToLoginPage():
import MultiWindowsLogIn

guiWindow = Tk()
guiWindow.title(“Student Registration System”)

backButton = Button(guiWindow, text=“Back to Login Window”, font=(‘times new roman’, 15, ‘bold’), bd=3, command=backToLoginPage), y=100)


Please help me to solve the issue, If there is some other way to achieve the desired output then please let me know…Thanks

sorry, this is a little confusing. Can you please rephrase? Thanks.

Also did you run tests, do you have any error messages that you can share? It’s hard to debug code that uses libraries by looking at it, who knows what happens under the hood.