The code below works perfect. However, what I noticed is that when I use withdraw() and deiconify() and then click on the x close button of the window and try to run my code again, my visual studio IDE does not start up my program. I have to close the IDE and then open it again to make it work. This only happens when I am using withdraw() and deiconify(). Why is this happening?
***main.py***
import tkinter as tk
from tkinter import ttk
import subprocess
import time
from tkinter import*
from tkinter import messagebox
from log import mainDashboardWindow
def login():
try:
messagebox.showinfo("Success", "Login Successful!")
loginWindow.withdraw()
mainDashboardWindow(loginWindow,"session") #If successful login, display user dashboard
except:
messagebox.showerror("Message","Unable To Connect")
if __name__ == '__main__':
loginWindow = Tk()
loginWindow.title('Login')
loginWindow.geometry('925x500+300+200')
loginWindow.configure(bg="#fff")
loginWindow.resizable(False,False)
logonBtn = Button(loginWindow,width=43,pady=7,text='Login',bg='#57a1f8',fg='white',cursor='hand2',border=0,command= lambda : login()).place(x=30,y=230)
mainloop()
***log.py***
import tkinter as tk
from turtle import color, width
from tkinter import*
from tkinter import ttk
from tkinter import messagebox
def logout(dashboardWindow,loginWindow):
dashboardWindow.withdraw()
loginWindow.deiconify()
print("Logout of sap")
def mainDashboardWindow(loginWindow,session):
dashboardWindow = Tk()
dashboardWindow.title('Dashboard')
dashboardWindow.geometry('925x500+300+200')
dashboardWindow.configure(bg="#fff")
dashboardWindow.resizable(False,False)
logoutBtn = Button(dashboardWindow,width=19,pady=7,text='Logout',bg='#57a1f8',fg='white',cursor='hand2',border=0,command= lambda : logout(dashboardWindow,loginWindow))
logoutBtn.pack(padx=(0,30),pady=(30,30),side=tk.RIGHT)