B osrcCs2tr*|jdd}|dkr dSd|SdSdS)a2 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. info patchlevel)z8.5.7z8.5.9FzWARNING: The version of Tcl/Tk ({0}) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information.N)rrr format)rrrrrtkVersionWarningGs rc CsNtdkr dStd}y t|d }t|SQRXWntk rHdSXdS)z- Fetch the macOS system preferences. rNz.~/Library/Preferences/.GlobalPreferences.plistrb)rropenplistlibloadOSError)Z plist_pathZ plist_filerrrreadSystemPreferences\s rcCs,tdkr dSt}|r(|ddkr(dSdS)zJ Warn if "Prefer tabs when opening documents" is set to "Always". rNZAppleWindowTabbingModealwayszWARNING: The system preference "Prefer tabs when opening documents" is set to "Always". This will cause various problems with IDLE. For the best experience, change this setting when running IDLE (via System Preferences -> Dock).)rrget)ZprefsrrrpreferTabsPreferenceWarningks r"csfdd}|d|dS)z This ensures that the application will respond to open AppleEvents, which makes is feasible to use IDLE as the default application for python files. csx|D]}|qWdS)N)r)argsfn)flistrr doOpenFiles z'addOpenEventSupport..doOpenFilez::tk::mac::OpenDocumentN) createcommand)rr%r&r)r%raddOpenEventSupports r(cCs.y|jddWntjk r(YnXdS)NZconsoleZhide)rr r ZTclError)rrrr hideTkConsolesr)c sddlm}ddlm}ddlm|jddd}|jdddd=|jddd ||jd ddd =|jdddd =|}j|d i}||d dd|d <}|jd|dd|ffdd } |d%fdd } d&fdd } d'fdd }  d|  d|  d| rR dj  dj t r||ddd|d<}|jd |d!|jddd"dgftrĈ d#|  d$| |jd dd=dS)(zf Replace the Tk root menu by something that is more appropriate for IDLE with an Aqua Tk. r)Menu)mainmenu)windowN)menur,)nameZtearoffZWindow)labelr3Z underlinecs8|d}|dkrd}|dkr*|d||dS)Nendr1r)indexdeleteZadd_windows_to_menu)r3r6)r,rrpostwindowsmenus   z)overrideRootMenu..postwindowsmenucsddlm}|dS)zHandle Help 'About IDLE' event.r) help_aboutN)idlelibr:Z AboutDialog)eventr:)rrr about_dialogs z&overrideRootMenu..about_dialogcs$ddlm}j_|ddS)z&Handle Options 'Configure IDLE' event.r) configdialogZSettingsN)r;r>Z inversedictZ instance_dictZ ConfigDialog)r<r>)r%rrr config_dialogs z'overrideRootMenu..config_dialogcsddlm}|dS)zHandle Help 'IDLE Help' event.r)helpN)r;r@Z show_idlehelp)r<r@)rrr help_dialogs z%overrideRootMenu..help_dialogz<>z<>z::tk::mac::ShowPreferencesz<>exitZappleZ applicationZIDLE)r5r3)z About IDLEz<>Z tkAboutDialogz::tk::mac::ShowHelp)N)N)N)r r*r;r+r,ZmenudefsinsertZ configureZ add_cascadeZregister_callbackZbindr'Zclose_all_callbackrr) rr%r*r+Z closeItemZmenubarZmenudictr3r9r=r?rAr)r%rr,roverrideRootMenusH            rDcCs(|dd|dd|dddS)zRemoved bad AquaTk Button-2 (right) and Paste bindings. They prevent context menu access and seem to be gone in AquaTk8.6. See issue #24801. ZTextzz z<>N)Z unbind_class)rrrr fixb2contexts  rEcCs.tr*t|t||t||t|dS)a 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)rr)rDr(rE)rr%rrrsetupApps   rF__main__)mainzidlelib.idle_test.test_macosxr2) verbosity)__doc__Zos.pathrrsysrr r rrrrrrrr"r(r)rDrErF__name__ZunittestrHrrrrs*    h