Author ned.deily
Recipients ned.deily
Date 2014-02-10.10:10:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
On OS X, most of the IDLE command keyboard accelerators that use the OS X <Option> modifier key do not work correctly with Cocoa Tk, the current native version of Tk 8.5 and 8.6 used on OS X 10.6 and later releases (and with the 64-/32-bit OS X binary installers from  These include the event bindings found in config-extensions.def:
and in config-keys.def (IDLE Classic OSX set): 
    save-copy-of-window-as-file = <Option-Command-Key-s>

These all work (mostly) correctly with the older Carbon Tk, the original 32-bit-only native Tk for OS X, still shipped as Tk 8.4 in current systems (and still used with the 32-bit-only binary installers), which was the Tk in use when native support for IDLE on OS X was originally implemented.

Modifier key support in Tk has long been problematic, with significant differences among platforms and even among the three implementations of Tk in use on OS X (besides the Cocoa and Carbon versions, there is an older OS X X11 version that differs in some respects from other Unix X11 versions).  Some of these differences have their origins lost in the mists of time or were due to no-longer relevant operating systems or hardware differences.  On the Tcl/Tk wiki, there is a page that attempts to document the differences based on empirical evidence (  Of particular relevance to IDLE is that the OS X Tk implementations do not use Alt binding modifiers since there was historically no Alt key on Mac keyboards.  In its place the Option key and binding modifier is used.  Likewise, the Command/Apple/⌘ key is used in place of the Windows key and is a binding modifier.  To that end, on OS X IDLE converts <Alt-> bindings and accelerators to <Opt-> ones, either during the build of IDLE or at run-time.  As noted above, that works pretty well for the older, now obsolete Carbon Tk.  However, it doesn't with the newer, current Cocoa Tk.  I believe this is primarily because Cocoa Tk supports the more sophisticated Cocoa text input system which maps most <Opt-> key combinations either directly to extended characters (like opt-s -> ß on US keyboard input methods) or as the first key of a two key composing sequence (e.g. opt-u a -> ä).  Cocoa Tk applications do not see these keys as separate events, only the final composed character.  Thus, the config-extension bindings above cause various characters to be input as text rather than triggering menu options.

The "save-copy-of-window-as-file" binding behaves somewhat differently: when typing Opt-Cmd-s, two instances of the Save File popup window appear with Cocoa Tk.  That erroneous behavior can be fixed by the straightforward change of the binding to <Control-Command-Key-s>.  Similar remapping to unused key bindings should be made for the extension bindings and documented accordingly so that all keyboard accelerators shown in IDLE menus are actually usable.

(For completeness sake, I'll note that the situation with OS X X11-based Tk in conjunction with the OS X XQuartz X server is much more bizarre.  Behavior differs depending on server preferences: either the roles of the Option and Command key modifiers are reversed or the Option modifier is not usable in Tk at all other than as an extended character set composing key.  The Tk wiki page documents much of this.  It isn't clear how a Tk application could accommodate all these different behaviors automatically so the current strategy of not trying to seems prudent.)
Date User Action Args
2014-02-10 10:10:42ned.deilysetrecipients: + ned.deily
2014-02-10 10:10:42ned.deilysetmessageid: <>
2014-02-10 10:10:42ned.deilylinkissue20579 messages
2014-02-10 10:10:39ned.deilycreate