mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00

svn+ssh://pythondev@svn.python.org/python/trunk ........ r74277 | sean.reifschneider | 2009-08-01 18:54:55 -0500 (Sat, 01 Aug 2009) | 3 lines - Issue #6624: yArg_ParseTuple with "s" format when parsing argument with NUL: Bogus TypeError detail string. ........ r74321 | guilherme.polo | 2009-08-05 11:51:41 -0500 (Wed, 05 Aug 2009) | 1 line Easier reference to find (at least while svn continues being used). ........ r74323 | guilherme.polo | 2009-08-05 18:48:26 -0500 (Wed, 05 Aug 2009) | 1 line Typo. ........ r74326 | jesse.noller | 2009-08-05 21:05:56 -0500 (Wed, 05 Aug 2009) | 1 line Fix issue 4660: spurious task_done errors in multiprocessing, remove doc note for from_address ........ r74355 | gregory.p.smith | 2009-08-12 12:02:37 -0500 (Wed, 12 Aug 2009) | 2 lines comment typo fix ........ r74465 | vinay.sajip | 2009-08-15 18:23:12 -0500 (Sat, 15 Aug 2009) | 1 line Added section on logging to one file from multiple processes. ........ r74467 | vinay.sajip | 2009-08-15 18:34:47 -0500 (Sat, 15 Aug 2009) | 1 line Refined section on logging to one file from multiple processes. ........ r74488 | vinay.sajip | 2009-08-17 08:14:37 -0500 (Mon, 17 Aug 2009) | 1 line Further refined section on logging to one file from multiple processes. ........ r74492 | r.david.murray | 2009-08-17 14:26:49 -0500 (Mon, 17 Aug 2009) | 2 lines Issue 6685: 'toupper' -> 'upper' in cgi doc example explanation. ........ r74513 | skip.montanaro | 2009-08-18 09:37:52 -0500 (Tue, 18 Aug 2009) | 1 line missing module ref (issue6723) ........ r74531 | vinay.sajip | 2009-08-20 17:04:32 -0500 (Thu, 20 Aug 2009) | 1 line Added section on exceptions raised during logging. ........ r74549 | benjamin.peterson | 2009-08-24 12:42:36 -0500 (Mon, 24 Aug 2009) | 1 line fix pdf building by teaching latex the right encoding package ........ r74553 | r.david.murray | 2009-08-26 20:04:59 -0500 (Wed, 26 Aug 2009) | 2 lines Remove leftover text from end of sentence. ........ r74625 | benjamin.peterson | 2009-09-01 17:27:57 -0500 (Tue, 01 Sep 2009) | 1 line remove the check that classmethod's argument is a callable ........ r74632 | georg.brandl | 2009-09-03 02:27:26 -0500 (Thu, 03 Sep 2009) | 1 line #6828: fix wrongly highlighted blocks. ........ r74643 | georg.brandl | 2009-09-04 01:59:20 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module. ........ r74644 | georg.brandl | 2009-09-04 02:55:14 -0500 (Fri, 04 Sep 2009) | 1 line #5047: remove Monterey support from configure. ........ r74647 | georg.brandl | 2009-09-04 03:17:04 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented. ........ r74652 | georg.brandl | 2009-09-04 06:25:37 -0500 (Fri, 04 Sep 2009) | 1 line #6756: add some info about the "acct" parameter. ........ r74666 | georg.brandl | 2009-09-05 04:04:09 -0500 (Sat, 05 Sep 2009) | 1 line #6841: remove duplicated word. ........ r74671 | georg.brandl | 2009-09-05 11:47:17 -0500 (Sat, 05 Sep 2009) | 1 line #6843: add link from filterwarnings to where the meaning of the arguments is covered. ........ r74727 | benjamin.peterson | 2009-09-08 18:04:22 -0500 (Tue, 08 Sep 2009) | 1 line #6865 fix ref counting in initialization of pwd module ........ r74739 | georg.brandl | 2009-09-11 02:55:20 -0500 (Fri, 11 Sep 2009) | 1 line Move function back to its section. ........
138 lines
4.9 KiB
Python
138 lines
4.9 KiB
Python
"""
|
|
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 if Python is running from within an app on OSX.
|
|
If so, assume that Python was built with Aqua Tcl/Tk rather than
|
|
X11 Tcl/Tk.
|
|
"""
|
|
return (sys.platform == 'darwin' and '.app' in sys.executable)
|
|
|
|
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):
|
|
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):
|
|
"""
|
|
Replace the Tk root menu by something that's more appropriate for
|
|
IDLE.
|
|
"""
|
|
# The menu that is attached to the Tk root (".") is also used by AquaTk for
|
|
# all windows that don't specify a menu of their own. The default menubar
|
|
# contains a number of menus, none of which are appropriate for IDLE. The
|
|
# Most annoying of those is an 'About Tck/Tk...' menu in the application
|
|
# menu.
|
|
#
|
|
# This function replaces the default menubar by a mostly empty one, it
|
|
# should only contain the correct application menu and the window menu.
|
|
#
|
|
# Due to a (mis-)feature of TkAqua the user will also see an empty Help
|
|
# menu.
|
|
from tkinter import Menu, Text, Text
|
|
from idlelib.EditorWindow import prepstr, get_accelerator
|
|
from idlelib import Bindings
|
|
from idlelib import WindowList
|
|
from idlelib.MultiCall import MultiCallCreator
|
|
|
|
menubar = Menu(root)
|
|
root.configure(menu=menubar)
|
|
menudict = {}
|
|
|
|
menudict['windows'] = menu = Menu(menubar, name='windows')
|
|
menubar.add_cascade(label='Window', menu=menu, underline=0)
|
|
|
|
def postwindowsmenu(menu=menu):
|
|
end = menu.index('end')
|
|
if end is None:
|
|
end = -1
|
|
|
|
if end > 0:
|
|
menu.delete(0, end)
|
|
WindowList.add_windows_to_menu(menu)
|
|
WindowList.register_callback(postwindowsmenu)
|
|
|
|
menudict['application'] = menu = Menu(menubar, name='apple')
|
|
menubar.add_cascade(label='IDLE', menu=menu)
|
|
|
|
def about_dialog(event=None):
|
|
from idlelib import aboutDialog
|
|
aboutDialog.AboutDialog(root, 'About IDLE')
|
|
|
|
def config_dialog(event=None):
|
|
from idlelib import configDialog
|
|
|
|
# Ensure that the root object has an instance_dict attribute,
|
|
# mirrors code in EditorWindow (although that sets the attribute
|
|
# on an EditorWindow instance that is then passed as the first
|
|
# argument to ConfigDialog)
|
|
root.instance_dict = flist.inversedict
|
|
root.instance_dict = flist.inversedict
|
|
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)
|
|
|
|
|
|
###check if Tk version >= 8.4.14; if so, use hard-coded showprefs binding
|
|
tkversion = root.tk.eval('info patchlevel')
|
|
# Note: we cannot check if the string tkversion >= '8.4.14', because
|
|
# the string '8.4.7' is greater than the string '8.4.14'.
|
|
if tuple(map(int, tkversion.split('.'))) >= (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:
|
|
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,
|
|
command=command, accelerator=accelerator)
|
|
|
|
def setupApp(root, flist):
|
|
"""
|
|
Perform setup for the OSX application bundle.
|
|
"""
|
|
if not runningAsOSXApp(): return
|
|
|
|
hideTkConsole(root)
|
|
overrideRootMenu(root, flist)
|
|
addOpenEventSupport(root, flist)
|