diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2006-06-11 14:33:36 +0000 |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2006-06-11 14:33:36 +0000 |
commit | 19302d927e6688e02553df16177e4867e2d0e3b3 (patch) | |
tree | 38fbc0f20e5b05833d09a560ea8d081393f19768 /Lib/idlelib/macosxSupport.py | |
parent | 6aaccc6b55a684771abfdad74bea742c25ded506 (diff) | |
download | cpython-git-19302d927e6688e02553df16177e4867e2d0e3b3.tar.gz |
This patch improves the L&F of IDLE on OSX. The changes are conditionalized on
being in an IDLE.app bundle on darwin. This does a slight reorganisation of the
menus and adds support for file-open events.
Diffstat (limited to 'Lib/idlelib/macosxSupport.py')
-rw-r--r-- | Lib/idlelib/macosxSupport.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosxSupport.py new file mode 100644 index 0000000000..d403514394 --- /dev/null +++ b/Lib/idlelib/macosxSupport.py @@ -0,0 +1,36 @@ +""" +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 + +def runningAsOSXApp(): + """ Returns True iff running from the IDLE.app bundle on OSX """ + return (sys.platform == 'darwin' and 'IDLE.app' in sys.argv[0]) + +def addOpenEventSupport(root, flist): + """ + This ensures that the application will respont to open AppleEvents, which + makes is feaseable to use IDLE as the default application for python files. + """ + def doOpenFile(*args): + for fn in args: + flist.open(fn) + + # The command below is a hook in aquatk that is called whenever the app + # receives a file open event. The callback can have multiple arguments, + # one for every file that should be opened. + root.createcommand("::tk::mac::OpenDocument", doOpenFile) + +def hideTkConsole(root): + root.tk.call('console', 'hide') + + +def setupApp(root, flist): + """ + Perform setup for the OSX application bundle. + """ + if not runningAsOSXApp(): return + + hideTkConsole(root) + addOpenEventSupport(root, flist) |