IDLE for Mac: If you are using a Python from any current python.org Python installer for macOS (3.9.0+, 3.8.0+, or 3.7.2+), no further action is needed to use IDLE or tkinter. A built-in version of Tcl/Tk 8.6 will be used.
If you are using macOS 10.6 or later, the Apple-supplied Tcl/Tk 8.5 has serious bugs that can cause application crashes. If you wish to use IDLE for Mac or Tkinter, do not use the Apple-supplied Pythons. Instead, install and use a newer version of Python from python.org or a third-party distributor that supplies or links with a newer version of Tcl/Tk.
There are currently three major variants of Tk in common use on macOS:Tk On macOS
- Aqua Cocoa Tk
- A newer native implementation available as a universal 64-bit and 32-bit binary. This variant is the standard native macOS variant in Tk 8.6 and as of Tk 8.5.13. Aqua Cocoa support was backported to Tk 8.5 (prior to 8.5.13) and released by Apple starting with macOS 10.6 and by ActiveState starting with their 188.8.131.52 release.
- Aqua Carbon Tk
- Because it is implemented with older macOS Carbon interfaces, it is only available as a 32-bit binary (usually for Intel and PowerPC processors). Aqua Carbon Tk 8.4 is included with macOS releases 10.4 through 10.14 and is also available from ActiveState. Aqua Carbon variants of Tk 8.5 had been available as an ActiveState Community Download prior to ActiveTcl 8.5.9. As of 8.5.13, the Tk project no longer supports Carbon builds of Tk 8.5. 32-bit-only Python installers downloadable from this website for older Python releases were linked with Aqua Carbon Tk 8.4.
- X11 Tk
- The traditional platform-independent UNIX Tk implementation which requires an X11 server, such as the Apple X11.app available as an optional component in older macOS releases or from third-party distributors. 64-bit and 32-bit binaries can be built. While the Python installers downloadable from this website do not support X11 Tk, other distributors of Python for macOS may do so.
As of Python 3.7.0, 3.6.8, and 2.7.16, all current Python installers for macOS downloadable from python.org supply their own private copies of Tcl/Tk 8.6.8. They do not look for or use any third-party or system copies of Tcl/Tk. This is an Aqua Cocoa Tk.
This is an Aqua Cocoa Tk.
This release is included in macOS 10.7 through at least macOS 10.14. As of this writing, there are at least two known issues with Tk 8.5.9 that are present in Apple 8.5.9 Tk but fixed in more recent upstream 8.5 releases. The more serious problem is an immediate crash in Tk when entering a composition character, like Option-u on a US keyboard. (This problem is documented as Tk bug 2907388.) There is also the more general problem of input manager support for composite characters (Tk bug 3205153) which has also been fixed in more recent Tcl/Tk 8.5 releases. You can avoid these problems by using a current python.org installer or by using a third-party distribution of Python that does not use Apple 8.5.9 Tk. This is an Aqua Cocoa Tk.
This release is included in macOS 10.6. IDLE is known to hang or crash when used with the Apple 8.5.7 included in all versions of macOS 10.6.x. Because of this, we strongly recommend that you do not attempt to use Tkinter or IDLE with
IDLE for Mac
IDLE for Mac lets you choose actions to perform when you are inactive for a certain period of time. For example, you can set up Idle to pause iTunes when you are away.Supported actions:
- Play/Pause VLC
- Play/Pause QuickTime
- Open Finder
- Hide All Applications
- Get New Mail
- Play/Pause iTunes
- Open Any Application, File or Script
the Apple-supplied Python 2.6.1 in 10.6. Instead, install a newer version of Python that supports a newer version of Tk. This is an Aqua Cocoa Tk.
How Python Chooses Which Tk Library To Use
While Tcl and Tk are separate frameworks and libraries, they are closely related and are normally installed or updated simultaneously. You should not attempt to mix-and-match Tcl and Tk versions. References to a specific version of Tk assume the corresponding version of Tcl is installed as well.
The Python for macOS installers downloaded from this website dynamically link at runtime to Tcl/Tk macOS frameworks. The Tcl/Tk major version is determined when the installer is created and cannot be overridden. All current python.org installers for Python 3.7.x, 3.6.x, and 2.7.x link to their own built-in Tcl/Tk 8.6 frameworks and do not use external Tcl/Tk frameworks so the rest of this section only applies to non-current releases and, as such, no longer supported.
Python 64-bit/32-bit macOS installers for
The Python 64-bit/32-bit macOS installers for Python 3.6.x and and 2.7.x dynamically link to Tcl/Tk 8.5 frameworks. The dynamically linking occurs when tkinter (Python 3) or Tkinter (Python 2) is first imported (specifically, the internal _tkinter C extension module). By default, the macOS dynamic linker looks first in /Library/Frameworks for Tcl and Tk frameworks with the proper major version. This is the standard location for third-party or built from source frameworks, including the ActiveTcl releases. If frameworks of the proper major version are not found there, the dynamic linker looks for the same version in /System/Library/Frameworks, the location for Apple-supplied frameworks shipped with macOS. (Note, you should normally not modify or delete files in /System/Library.)
As is common on macOS, the installed Pythons and the Tcl and Tk frameworks are built to run on multiple CPU architectures (universal binaries) and across multiple macOS levels (minimum deployment target). For Python to be able to dynamically link with a particular Tcl and Tk version, the available architectures in the Tcl/Tk frameworks must include the architecture that Python is running in and their minimum deployment target should be no greater than that of Python.
Its worth spending a bit of time describing how to use IDLE. To most, this may not be immediately obvious.
Launch IDLE shell window
To start, we need to open the python shell window. This is the first window you see when you launch the IDLE application. If you haven’t already, drag the IDLE icon from your Launchpad down into the dock. This will ensure it is ever present whenever you wish to launch.
Open editor window
From the shell window, you need to open an editor window. The editor window is where we will write python code. From the IDLE menu bar (click on the shell window to ensure the menu bar is IDLE for Mac specific) click File, New File. This will open a new window called “Untitled”
Its probably a good idea to save the editor window file at this point. This will ensure your code can be saved as you work on it, and it can be retrieved at a later point. From the menu bar, click File, Save As. Each Python file name will have a .py extension. This is provided by default when you name your file.
Write some code
I wanted to prove that my set up worked so I entered some code in the editor window. I wrote a hello world program using the code below. Click File, Save on the IDLE menu when this code has been written in the editor window.
print ("Hello World")
Executing the code returns (prints) the string values (within quotation marks) stored inside brackets to the python shell window. On the IDLE menu bar click Run, Run Module. This returns the output shown below to the shell window.
Code written and successfully returned to the shell window! To follow on from my previous post, rubber has in fact hit the road. I now have a set up that works and the tools that I need to start learning Python.
Sidenote – Thewebsite has a a comprehensive guide on using IDLE which goes well beyond this post. For more detail, this is a great place to look.
Python’s integrated development environment, IDLE, and the tkinter GUI toolkit it uses, depend on the Tk GUI toolkit which is not part of Python itself. For best results, it is important that the proper release of Tcl/Tk is installed on your machine. For recent Python installers for macOS downloadable from this website, here is a summary of current recommendations followed by more detailed information.