ó |G_Tc@s°dZddlZddlZddlmZddlZd„Zd„Zda d„Z d„Z d„Z d „Z d „Zd „Zd „Zd „Zd„Zd„ZdS(s5 A number of functions that enhance IDLE on Mac OSX. i˙˙˙˙N(tpathcCstjdtddƒtƒS(Ns/runningAsOSXApp() is deprecated, use isAquaTk()t stackleveli(twarningstwarntDeprecationWarningtisAquaTk(((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pytrunningAsOSXApp s  cCstjdtddƒtƒS(Ns4isCarbonAquaTk(root) is deprecated, use isCarbonTk()Ri(RRRt isCarbonTk(troot((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pytisCarbonAquaTks  cCsˆtjdkr~|jjddƒ}d|kr9daq„d|krNdaq„d|jjd d d ƒkrud aq„d andadS(sl Initializes OS X Tk variant values for isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz(). tdarwinttktwindowingsystemtx11txquartztaquatothertAppKittwinfotservert.tcocoatcarbonN(tsystplatformR tcallt_tk_type(Rtws((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyt_initializeTkVariantTestss      cCs(tdk st‚tdkp'tdkS(sK Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon). RRN(RtNonetAssertionError(((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyR*scCstdk st‚tdkS(sb Returns True if IDLE is using a Carbon Aqua Tk (instead of the newer Cocoa Aqua Tk). RN(RRR(((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyR1scCstdk st‚tdkS(s8 Returns True if IDLE is using a Cocoa Aqua Tk. RN(RRR(((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyt isCocoaTk9scCstdk st‚tdkS(s7 Returns True if IDLE is using an OS X X11 Tk. RN(RRR(((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyt isXQuartz@scCsCtƒr;|jjddƒ}|dkr.tSdj|ƒStSdS(s2 Returns a string warning message if the Tk version in use appears to be one known to cause problems with IDLE. 1. Apple Cocoa-based Tk 8.5.7 shipped with Mac OS X 10.6 is unusable. 2. Apple Cocoa-based Tk 8.5.9 in OS X 10.7 and 10.8 is better but can still crash unexpectedly. tinfot patchlevels8.5.7s8.5.9s†WARNING: The version of Tcl/Tk ({0}) in use may be unstable.\nVisit http://www.python.org/download/mac/tcltk/ for current information.N(s8.5.7s8.5.9(RR RtFalsetformat(RR"((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyttkVersionWarningGs  cs#‡fd†}|jd|ƒdS(s˘ This ensures that the application will respond to open AppleEvents, which makes is feasible to use IDLE as the default application for python files. cs"x|D]}ˆj|ƒqWdS(N(topen(targstfn(tflist(s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyt doOpenFile`s s::tk::mac::OpenDocumentN(t createcommand(RR)R*((R)s1/usr/local/lib/python2.7/idlelib/macosxSupport.pytaddOpenEventSupport[scCs2y|jjddƒWntjk r-nXdS(Ntconsolethide(R RtTkintertTclError(R((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyt hideTkConsoleiscsËddlm}m}m}ddlm}m}ddlm}ddlm‰ddl m }|j ddd }|j ddd 3|j ddj d |ƒ|j dddd 5|j d ddd 5|ˆƒ} ˆj d | ƒi} || ddƒ| d<} | jddd | ddƒ| ‡fd†} ˆj| ƒd(‡fd†} d(‡‡fd†}d(‡fd†}ˆjd| ƒˆjd|ƒˆjd|ƒˆr݈jdˆjƒˆjdˆjƒntƒr‰|| ddƒ| d<} | jddd | ƒ|j j ddd)d(gfƒˆjjd ƒ}ttt|jd!ƒƒƒd*kr‰|j ddjd+ƒq‰ntƒrLjjd&| ƒˆjd'|ƒ|j ddd=nd(S(,sf Replace the Tk root menu by something that is more appropriate for IDLE with an Aqua Tk. i˙˙˙˙(tMenutTextR3(tprepstrtget_accelerator(tBindings(t WindowList(tMultiCallCreatoriiiţ˙˙˙iý˙˙˙iitmenutnametwindowstlabeltWindowt underlinecsT|jdƒ}|dkr$d}n|dkrC|jd|ƒnˆj|ƒdS(Ntendi˙˙˙˙i(tindexRtdeletetadd_windows_to_menu(R9R?(R7(s1/usr/local/lib/python2.7/idlelib/macosxSupport.pytpostwindowsmenus    cs$ddlm}|jˆdƒdS(Ni˙˙˙˙(t aboutDialogs About IDLE(tidlelibRDt AboutDialog(teventRD(R(s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyt about_dialog§scs0ddlm}ˆjˆ_|jˆdƒdS(Ni˙˙˙˙(t configDialogtSettings(RERIt inversedictt instance_dictt ConfigDialog(RGRI(R)R(s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyt config_dialogŤs csKddlm}tjtjtjtƒƒdƒ}|jˆd|ƒdS(Ni˙˙˙˙(ttextViewshelp.txttHelp(RERORtjointabspathtdirnamet__file__t view_file(RGROR((R(s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyt help_dialog°s$s<>s<>s::tk::mac::ShowPreferencess<>texittapplet applicationtIDLEs About IDLEsinfo patchlevelRiiis_Preferences....t tkAboutDialogs::tk::mac::ShowHelpN(s About IDLEs<>(iii(s_Preferences....s<>(R/R2R3tidlelib.EditorWindowR4R5RER6R7tidlelib.MultiCallR8tmenudefstinsertt configuret add_cascadetregister_callbackRtbindR+tclose_all_callbackRR tevalttupletmaptinttsplittappendR(RR)R2R3R4R5R6R8t closeItemtmenubartmenudictR9RCRHRNRVt tkversion((R7R)Rs1/usr/local/lib/python2.7/idlelib/macosxSupport.pytoverrideRootMenupsR     $  cCs>t|ƒtƒr:t|ƒt||ƒt||ƒndS(sě Perform initial OS X customizations if needed. Called from PyShell.main() after initial calls to Tk() There are currently three major versions of Tk in use on OS X: 1. Aqua Cocoa Tk (native default since OS X 10.6) 2. Aqua Carbon Tk (original native, 32-bit only, deprecated) 3. X11 (supported by some third-party distributors, deprecated) There are various differences among the three that affect IDLE behavior, primarily with menus, mouse key events, and accelerators. Some one-time customizations are performed here. Others are dynamically tested throughout idlelib by calls to the isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which are initialized here as well. N(RRR1RoR,(RR)((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pytsetupApp×s     (t__doc__RR/tosRRRR RRRRRRR R%R,R1RoRp(((s1/usr/local/lib/python2.7/idlelib/macosxSupport.pyts"              g