Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/idlelib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from tkinter.font import Font
import idlelib
from idlelib import macosx

class InvalidConfigType(Exception): pass
class InvalidConfigSet(Exception): pass
Expand Down Expand Up @@ -660,6 +661,9 @@ def GetCoreKeys(self, keySetName=None):
'<<zoom-height>>': ['<Alt-Key-2>'],
}

if macosx.isAquaTk():
del keyBindings['<<close-all-windows>>']

if keySetName:
if not (self.userCfg['keys'].has_section(keySetName) or
self.defaultCfg['keys'].has_section(keySetName)):
Expand Down
21 changes: 16 additions & 5 deletions Lib/idlelib/macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

_tk_type = None

def _on_quit():
# on quit callback, overridden in setupApp
pass

def _init_tk_type():
""" Initialize _tk_type for isXyzTk functions.

Expand All @@ -34,6 +38,12 @@ def _init_tk_type():
return

root = tkinter.Tk()

# Add an ::tk::mac::Quit command to the root because Tk
# seem to only call the quit command created in the
# first `tkinter.Tk` instance.
root.createcommand('::tk::mac::Quit', lambda: _on_quit())

ws = root.tk.call('tk', 'windowingsystem')
if 'x11' in ws:
_tk_type = "xquartz"
Expand Down Expand Up @@ -158,6 +168,7 @@ def overrideRootMenu(root, flist):
from idlelib import mainmenu
from idlelib import window


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray newline?

closeItem = mainmenu.menudefs[0][1][-2]

# Remove the last 3 items of the file menu: a separator, close window and
Expand Down Expand Up @@ -216,13 +227,13 @@ def help_dialog(event=None):
root.bind('<<open-config-dialog>>', config_dialog)
root.createcommand('::tk::mac::ShowPreferences', config_dialog)
if flist:
root.bind('<<close-all-windows>>', 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', flist.close_all_callback)

# Override the _on_quit helper, see comment in
# _init_tk_type for the background on this
global _on_quit
_on_quit = flist.close_all_callback

if isCarbonTk():
# for Carbon AquaTk, replace the default Tk apple menu
menu = Menu(menubar, name='apple', tearoff=0)
Expand Down