0

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?

Smets
  • 5
  • 2
  • some programs save normal text file `program_name.lock` with `Process ID` at start and delete it at the end. If file exists when program starts then it means program is already running. – furas Jan 24 '20 at 10:25
  • 1
    Does this answer your question? [Make sure only a single instance of a program is running](https://stackoverflow.com/questions/380870/make-sure-only-a-single-instance-of-a-program-is-running) – stovfl Jan 24 '20 at 10:41

0 Answers0