I have written a program in python which continuously monitors the content of a given folder in windows. When something changes in this folder the program acts upon it. Because I want the user to be able to change the given folder I created a GUI with tkinter. Now when the user closes the window I made sure only the window closes by using root.protocol("WM_DELETE_WINDOW", root.withdraw). This way I am making sure the program keeps running in the background and the given folder is still being monitored. Now I would like to just show the window again when the user starts the program again. What happens at the moment is that the program is being started a second time with the first startup still running in the background.
What I wanted to do first is save the tkinter object to a file. When I would start the program again I could check if the program is already running first, and if it is, just do root.deiconify with root being the saved tkinter object. However, it is not possible to save a tkinter object to a file in the first place. Is there any way of doing this properly?