diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2007-07-09 06:02:21 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2007-07-09 06:02:21 (GMT) |
commit | 9b0bcc1f4b7aeb6eb2591aebf4688fa2ffe46f4d (patch) | |
tree | f0230933cc9bd769a5c21723d4cfc1969231f6e7 /Lib/idlelib | |
parent | e3b185f9667488695035983bbbaa84616e6149e2 (diff) | |
download | cpython-9b0bcc1f4b7aeb6eb2591aebf4688fa2ffe46f4d.zip cpython-9b0bcc1f4b7aeb6eb2591aebf4688fa2ffe46f4d.tar.gz cpython-9b0bcc1f4b7aeb6eb2591aebf4688fa2ffe46f4d.tar.bz2 |
Patch 1693258: Fix for duplicate "preferences" menu-OS X
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/macosxSupport.py | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosxSupport.py index ad61fff..222abfc 100644 --- a/Lib/idlelib/macosxSupport.py +++ b/Lib/idlelib/macosxSupport.py @@ -3,6 +3,7 @@ A number of function that enhance IDLE on MacOSX when it used as a normal GUI application (as opposed to an X11 application). """ import sys +import Tkinter def runningAsOSXApp(): """ Returns True iff running from the IDLE.app bundle on OSX """ @@ -23,7 +24,11 @@ def addOpenEventSupport(root, flist): root.createcommand("::tk::mac::OpenDocument", doOpenFile) def hideTkConsole(root): - root.tk.call('console', 'hide') + try: + root.tk.call('console', 'hide') + except Tkinter.TclError: + # Some versions of the Tk framework don't have a console object + pass def overrideRootMenu(root, flist): """ @@ -75,32 +80,40 @@ def overrideRootMenu(root, flist): import configDialog configDialog.ConfigDialog(root, 'Settings') + root.bind('<<about-idle>>', about_dialog) root.bind('<<open-config-dialog>>', config_dialog) if flist: root.bind('<<close-all-windows>>', flist.close_all_callback) - for mname, entrylist in Bindings.menudefs: - menu = menudict.get(mname) - if not menu: - continue - for entry in entrylist: - if not entry: - menu.add_separator() + + ###check if Tk version >= 8.4.14; if so, use hard-coded showprefs binding + tkversion = root.tk.eval('info patchlevel') + if tkversion >= '8.4.14': + Bindings.menudefs[0] = ('application', [ + ('About IDLE', '<<about-idle>>'), + None, + ]) + root.createcommand('::tk::mac::ShowPreferences', config_dialog) + else: + for mname, entrylist in Bindings.menudefs: + menu = menudict.get(mname) + if not menu: + continue else: - label, eventname = entry - underline, label = prepstr(label) - accelerator = get_accelerator(Bindings.default_keydefs, + for entry in entrylist: + if not entry: + menu.add_separator() + else: + label, eventname = entry + underline, label = prepstr(label) + accelerator = get_accelerator(Bindings.default_keydefs, eventname) - def command(text=root, eventname=eventname): - text.event_generate(eventname) - menu.add_command(label=label, underline=underline, + def command(text=root, eventname=eventname): + text.event_generate(eventname) + menu.add_command(label=label, underline=underline, command=command, accelerator=accelerator) - - - - def setupApp(root, flist): """ Perform setup for the OSX application bundle. |