Skip to content

Commit

Permalink
pythongh-112898: warn about unsaved files when quitting IDLE on macOS
Browse files Browse the repository at this point in the history
Implement the TK function ``::tk::mac::Quit`` on macOS to
ensure that IDLE asks about saving unsaved files when
quitting IDLE.
  • Loading branch information
ronaldoussoren committed Dec 10, 2023
1 parent 2d76be2 commit daa6ac5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Lib/idlelib/macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ def doOpenFile(*args):
# one for every file that should be opened.
root.createcommand("::tk::mac::OpenDocument", doOpenFile)

def addQuitSupport(root, flist):
"""
This ensures that the application will respond properly to quit events,
including the "IDLE -> Quit IDLE" menu.
"""
def doQuit():
flist.close_all_callback()

root.createcommand("::tk::mac::Quit", doQuit)

def hideTkConsole(root):
try:
root.tk.call('console', 'hide')
Expand Down Expand Up @@ -270,6 +280,7 @@ def setupApp(root, flist):
hideTkConsole(root)
overrideRootMenu(root, flist)
addOpenEventSupport(root, flist)
addQuitSupport(root, flist)
fixb2context(root)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix processing unsaved files when quitting IDLE on macOS.

0 comments on commit daa6ac5

Please sign in to comment.