o =?h'@sdZddlmZddlZddlmZddlZdaddZddZ d d Z d d Z d dZ ddZ ddZddZddZddZddZddZddZedkr^dd lmZed!d"d#dSdS)$z3 A number of functions that enhance IDLE on macOS. ) expanduserN)platformcCstdkrUddlm}|r'ddlm}m}z|dWn |y&daYdSwt}|j dd }d |vr9d and |vr@d and|j dddvrMdanda| dSd adS)zu Initialize _tk_type for isXyzTk functions. This function is only called once, when _tk_type is still None. darwinr)testing)requiresResourceDeniedZguicocoaNtkZwindowingsystemZx11xquartzZaquaotherZAppKitZwinfoZserver.carbon) rZidlelib.__init__rZ test.supportrr_tk_typetkinterZTkr callZdestroy)rrrrootZwsr5/opt/alt/python310/lib64/python3.10/idlelib/macosx.py _init_tk_types.   rcCststtdkp tdkS)zK Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon). rr rrrrrrisAquaTk3srcCtsttdkS)zb Returns True if IDLE is using a Carbon Aqua Tk (instead of the newer Cocoa Aqua Tk). r rrrrr isCarbonTk;srcCr)z8 Returns True if IDLE is using a Cocoa Aqua Tk. rrrrrr isCocoaTkDrcCr)z7 Returns True if IDLE is using an OS X X11 Tk. r rrrrr isXQuartzLrrcCs.tr|jdd}|dvrdSd|SdS)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 https://www.python.org/download/mac/tcltk/ for current information.)rr rformat)rrrrrtkVersionWarningUs rcCsftdkrdStd}zt|d}t|WdWS1s!wYWdSty2YdSw)z- Fetch the macOS system preferences. rNz.~/Library/Preferences/.GlobalPreferences.plistrb)rropenplistlibloadOSError)Z plist_pathZ plist_filerrrreadSystemPreferencesjs ( r%cCs.tdkrdSt}|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).)rr%get)ZprefsrrrpreferTabsPreferenceWarningysr(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. cs|D]}|qdSN)r!)argsfnflistrr doOpenFiles z'addOpenEventSupport..doOpenFilez::tk::mac::OpenDocumentN) createcommand)rr-r.rr,raddOpenEventSupports r0cCs,z |jddWdStjyYdSw)NZconsoleZhide)r rrZTclErrorrrrr hideTkConsoles r2c 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| r dj  dj t r||ddd|d<}|jd |d!|jddd"dgftr d#|  d$| |jd dd=dSdS)&zf Replace the Tk root menu by something that is more appropriate for IDLE with an Aqua Tk. r)Menu)mainmenuwindowN)menur6)nameZtearoffZWindow)labelr=Z underlinecs8|d}|dur d}|dkr|d||dS)Nendr;r)indexdeleteZadd_windows_to_menu)r=r@r5rrpostwindowsmenus  z)overrideRootMenu..postwindowsmenucddlm}|dS)zHandle Help 'About IDLE' event.r) help_aboutN)idlelibrEZ AboutDialog)eventrEr1rr about_dialog z&overrideRootMenu..about_dialogcs$ddlm}j_|ddS)z&Handle Options 'Configure IDLE' event.r) configdialogZSettingsN)rFrJZ inversedictZ instance_dictZ ConfigDialog)rGrJ)r-rrr config_dialogs z'overrideRootMenu..config_dialogcrD)zHandle Help 'IDLE Help' event.r)helpN)rFrLZ show_idlehelp)rGrLr1rr help_dialogrIz%overrideRootMenu..help_dialog<>z<>z::tk::mac::ShowPreferencesz<>exitZappleZ applicationZIDLE)r?r=)z About IDLErNZ tkAboutDialogz::tk::mac::ShowHelpr))rr3rFr4r6ZmenudefsinsertZ configureZ add_cascadeZregister_callbackZbindr/Zclose_all_callbackrr) rr-r3r4Z closeItemZmenubarZmenudictr=rCrHrKrMr)r-rr6roverrideRootMenusP          rQcCs(|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_classr1rrr fixb2context s  rRcCs2trt|t||t||t|dSdS)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)rr2rQr0rR)rr-rrrsetupApps    rS__main__)mainzidlelib.idle_test.test_macosxr<) verbosity)__doc__Zos.pathrr"sysrrrrrrrrrr%r(r0r2rQrRrS__name__ZunittestrUrrrrs.  #  h