From eda57502a75dd763413226a7bcaaa6a8d495313f Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Wed, 27 Dec 2023 18:36:41 +0100 Subject: [PATCH] Actually work with various quit events (menu, shortcut, osascript) --- Lib/idlelib/config.py | 7 +++++++ Lib/idlelib/macosx.py | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/config.py b/Lib/idlelib/config.py index 92992fd9cce9cd..bcf429862f35a7 100644 --- a/Lib/idlelib/config.py +++ b/Lib/idlelib/config.py @@ -31,6 +31,7 @@ from tkinter.font import Font import idlelib +from idlelib import macosx class InvalidConfigType(Exception): pass class InvalidConfigSet(Exception): pass @@ -660,6 +661,12 @@ def GetCoreKeys(self, keySetName=None): '<>': [''], } + if sys.platform == "darwin": + # XXX: ^^^ This test should be macosx.isAquaTk(), + # but that has some side effect that results in not + # calling the quit event handler. + del keyBindings['<>'] + if keySetName: if not (self.userCfg['keys'].has_section(keySetName) or self.defaultCfg['keys'].has_section(keySetName)): diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py index 683817d1ae38a2..aca5c5f31cf0d7 100644 --- a/Lib/idlelib/macosx.py +++ b/Lib/idlelib/macosx.py @@ -216,12 +216,10 @@ def help_dialog(event=None): root.bind('<>', config_dialog) root.createcommand('::tk::mac::ShowPreferences', config_dialog) if flist: - root.bind('<>', flist.close_all_callback) - # The binding above doesn't reliably work on all versions of Tk # on macOS. Adding command definition below does seem to do the # right thing for now. - root.createcommand('::tk::mac::Quit', lambda: "break") + root.createcommand('::tk::mac::Quit', flist.close_all_callback) if isCarbonTk(): # for Carbon AquaTk, replace the default Tk apple menu