Skip to content

Commit

Permalink
Crude hack to make sure the quit command is called
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldoussoren committed Dec 27, 2023
1 parent b305b36 commit a84a2d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/idlelib/config-keys.def
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ cut=<Command-Key-x>
paste=<Command-Key-v>
beginning-of-line= <Key-Home>
center-insert=<Control-Key-l>
close-all-windows=<Key-F35>
close-all-windows=<Command-Key-q>
close-window=<Command-Key-w>
do-nothing=<Control-Key-F12>
end-of-file=<Control-Key-d>
Expand Down Expand Up @@ -264,7 +264,7 @@ redo = <Shift-Command-Key-Z>
close-window = <Command-Key-w>
restart-shell = <Control-Key-F6>
save-window-as-file = <Shift-Command-Key-S>
close-all-windows = <Key-F35>
close-all-windows = <Command-Key-q>
view-restart = <Key-F6>
tabify-region = <Control-Key-5>
find-again = <Command-Key-g> <Key-F3>
Expand Down
16 changes: 16 additions & 0 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


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

# Remove the last 3 items of the file menu: a separator, close window and
Expand Down Expand Up @@ -218,6 +229,11 @@ def help_dialog(event=None):
if flist:
root.createcommand('::tk::mac::Quit', flist.close_all_callback)

# Override the _on_quit helder, 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

0 comments on commit a84a2d7

Please sign in to comment.