[Tkinter-discuss] Accelerator keys cross-platform

Kevin Walzer kw at codebykevin.com
Fri Dec 25 21:19:48 EST 2015


I'm porting a Tkinter application from Mac to Windows and I need a 
cross-platform way to implement accelerator keys for menu entries. In 
Tcl, this is very simple:

  -accelerator "$Command-C"

where $Command can be set to "Command" or "Control" depending on the 
platform.

Python does not have as flexible a string substitution as Tcl, so I'm 
looking for a Pythonic way to do this. Most examples I've seen load 
entirely separate menus depending on the platform, and I'd rather avoid 
duplicating code that way.  Any suggestions or examples that anyone can 
share?

-- 
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com



More information about the Tkinter-discuss mailing list