-1

I am building a GUI with Tkinter at the moment. With the GUI I can create files, add certain lines to the files, delete lines, save and load files. My problem is, that i want to prevent the closing of the window if the current file wasn't saved. Is there a way to solve this problem?

Ted
  • 3
  • 2

1 Answers1

1

Yes. That is totally possible (unless perhaps the process is being terminated abruptly), by making use of WM_DELETE_WINDOW protocol:

...The most commonly used protocol is called WM_DELETE_WINDOW, and is used to define what happens when the user explicitly closes a window using the window manager.

Nae
  • 12,111
  • 5
  • 46
  • 74