Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23189

How to handle switching between windows (GUIs) in Python Tkinter?

$
0
0

Please help to resolve the issue in my Tkinter code… Actually, I want to switch between to widows (multiple times from window1 to window2 and backforht). I am using Python Tkinter gui library.

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 expects main GUI to open but not successfull…....My login page get closes but this does not open main GUI page again (in fact whole project gets closed)…why it so? please help me.

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

(2) Code of MultiWindowsLogIn.py is as:

`from tkinter import *
def login():logInWindow.quit()logInWindow.destroy()import mainGUI
logInWindow = Tk()logInWindow.title(“Login Window Title”)logInWindow.geometry(‘600x400’)
logInButton = Button(logInWindow, text=“Login”, width=15, font=(‘times new roman’, 15, ‘bold’), bd=2, command=login)logInButton.place(x=200,y=250)
logInWindow.mainloop()

(3) Code of mainGUI.py is as:

`from tkinter import *
def backToLoginPage():guiWindow.quit()guiWindow.destroy()import MultiWindowsLogIn
guiWindow = Tk()guiWindow.title(“Student Registration System”)guiWindow.geometry(‘500x200+0+0’)
backButton = Button(guiWindow, text=“Back to Login Window”, font=(‘times new roman’, 15, ‘bold’), bd=3, command=backToLoginPage)backButton.place(x=150, y=100)
guiWindow.mainloop()`

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


Viewing all articles
Browse latest Browse all 23189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>