Tcl Tk Download Mac

However, the default Mac Python installation may not include the correct version of Tcl/Tk to use Tkinter. Also, the Mac OS typically includes Python 2, whereas this course is oriented around. To make sure I get the R with tcl-tk I used the R version of @srfore. These are the subsequent commands. Brew cask install xquartz, install Xquartz. Although some suggested this should not be necessary. Brew install -s sethrfore/homebrew-r-srf/r, installed an edited version of R. Brew cask install rstudio, install Rstudio.

  • Submit New Release
  • Edit Tcl/Tk Information
  • Submit a New Software

Very powerful but easy to learn dynamic programming language.

Monday, January 4, 2021
  • Development
  • Languages
  • Other

Tcl (Tool Command Language) is a very powerful but easy to learn dynamic programming language, suitable for a very wide range of uses, including web and desktop applications, networking, administration, testing and many more. Open source and business-friendly, Tcl is a mature yet evolving language that is truly cross platform, easily deployed and highly extensible.

Tk is a graphical user interface toolkit that takes developing desktop applications to a higher level than conventional approaches. Tk is the standard GUI not only for Tcl, but for many other dynamic languages, and can produce rich, native applications that run unchanged across Windows, Mac OS X, Linux and more.

  • 17255
  • License
    GPL

Downloads / Release History


04
Tcl/Tk 8.6.11
15
Tcl/Tk 8.6.9
23
Tcl/Tk 8.6.8
10
Tcl/Tk 8.6.7
01
Tcl/Tk 8.6.6
18
Tcl/Tk 8.6.1
23
Tcl/Tk 8.6
21
Tcl/Tk 8.6 beta 3
11
Tcl/Tk 8.5.13
28
Tcl/Tk 8.5.12
16
Tcl/Tk 8.6 beta 2
16
Tcl/Tk 8.5.11
12
Tcl/Tk 8.5.6
12
Tcl/Tk 8.6 beta 1
12
Tcl/Tk 8.5.7
12
Tcl/Tk 8.5.4

Related Apps

Lazarus 2.0.8
Libraries for Free Pascal that emulate Delphi.
R 2.7.2
Language and environment for statistical computing and graphics.
Asymptote 2.46
Perl Dev Kit 8.0
The Perl Dev Kit (PDK) provides essential tools for building and deploying Perl applications.

Active Tcl Tk Download

Free Pascal 3.0.4
Gnome Basic 0.0.20
Seed7 05_20200830Tcl tk install
General purpose programming language.
Scala 2.13.1

Comments

Last articles


Important

If you are using a Python from any current python.orgPython 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-suppliedTcl/Tk 8.5 has serious bugs that can cause application crashes.If you wish to use IDLE or Tkinter, do not use the Apple-suppliedPythons. Instead, install and use a newer version of Pythonfrom python.org or a third-party distributor that supplies orlinks with a newer version of Tcl/Tk.

Python's integrated development environment,IDLE, and thetkinter GUI toolkitit uses, depend on the Tk GUI toolkit which isnot part of Python itself. For best results, it is important that theproper 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 detailedinformation.

PythonReleaseInstallerVariantmacOSReleaseRecommendedTcl/TkAlternateTcl/TkNotRecommended
3.9.0,3.8.6,3.7.9all10.9 to10.15built-in8.6.8

There are currently three major variants of Tk in common use on macOS:

Tkinter Documentation. Python and Tkinter Programming by John Grayson (see also GuiBooks). This book just recently came back into print on demand, see the publisher's website. Python GUI with Tkinter is a complete tutorial that covers all the widgets for the Tkinter library, complete with examples. Install Tkinter.I've included the win32api for as a Windows-only solution. Script #!/usr/bin/env python 'Get the current mouse position.' ' import logging import sys logging.basicConfig(format='%(asctime)s%(levelname)s%(message)s', level=logging.DEBUG, stream=sys.stdout) def getmouseposition: ' Get the current position of the mouse.

Aqua Cocoa Tk
A newer native implementation availableas a universal 64-bit and 32-bit binary. This variant is the standard nativemacOS variant in Tk 8.6 and as of Tk 8.5.13. Aqua Cocoa support wasbackported to Tk 8.5 (prior to 8.5.13) and released by Apple starting with macOS 10.6and by ActiveState starting with their 8.5.9.1 release.
Aqua Carbon Tk
Because it is implemented with older macOS Carbon interfaces, it isonly available as a 32-bit binary (usually for Intel and PowerPCprocessors). Aqua Carbon Tk 8.4 is included with macOS releases 10.4through 10.14 and is also available from ActiveState. Aqua Carbon variantsof Tk 8.5 had been available as an ActiveState Community Download priorto ActiveTcl 8.5.9. As of 8.5.13, the Tk project no longer supportsCarbon builds of Tk 8.5. 32-bit-only Python installers downloadablefrom this website for older Python releases were linked with Aqua CarbonTk 8.4.
X11 Tk
The traditional platform-independent UNIX Tk implementation whichrequires an X11 server, such as the Apple X11.app available as anoptional component in older macOS releases or from third-partydistributors. 64-bit and32-bit binaries can be built. While the Python installers downloadablefrom this website do not support X11 Tk, other distributors ofPython for macOS may do so.

built-in 8.6.8

Tkinter (Tk) is a Python default GUI and comes with the Python installation on Linux, Mac, and Windows. Since Tk comes with most Python installations, you don’t generally need to install it yourself. Since Python 2 and Python 3 vary so much, this wikiHow will show you how to install Tkinter with Python 3 on Windows, Linux, and Mac OS. Install Tk for Python (Tkinter) on Linux/X11. Tkinter (and, since Python 3.1, ttk, which is the interface to the newer themed widgets) is included in the Python standard library. It relies on Tcl/Tk being installed on your system. Depending on how you install Python, this may not happen automatically.

As of Python 3.7.0, 3.6.8, and 2.7.16, all current Python installers for macOSdownloadable from python.org supplytheir own private copies of Tcl/Tk 8.6.8. They do not look for or use anythird-party or system copies of Tcl/Tk. This is an Aqua Cocoa Tk.

ActiveTcl 8.5.18.0

ActiveState provides binary distributions of Tcl/Tk which are upward compatiblewith and generally more up-to-date than those provided by Apple in macOSreleases. This version of Tcl/Tk includes fixes for some critical problemsthat you may encounter using tkinter or IDLE (see Apple 8.5.9 below).You can download an installer for this release fromthe ActiveState web site.Note that ActiveState Community Edition binaries are not open source andare covered by an ActiveState license. You should read the licensebefore downloading to verify that your usage complies with its terms of use.As of Python 3.7.0, 3.6.8, and 2.7.16, no current Python installers for macOSdownloadable from python.org make use of this or any other external versionof Tcl/Tk.

This is an Aqua Cocoa Tk.

Apple 8.5.9

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 thatare 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 Tkwhen entering a composition character, like Option-u on a US keyboard.(This problem is documented asTk bug 2907388.)There is also the more general problem of input manager support for compositecharacters(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 installeror by using a third-partydistribution of Python that does not use Apple 8.5.9 Tk.This is an Aqua Cocoa Tk.

Apple 8.5.7

This release is included in macOS 10.6. IDLE is known to hang or crashwhen 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 withthe Apple-supplied Python 2.6.1 in 10.6. Instead, install a newer version ofPython that supports a newer version of Tk.This is an Aqua Cocoa Tk.

Note

While Tcl and Tk areseparate frameworks and libraries, they are closely related and arenormally installed or updated simultaneously. You should notattempt to mix-and-match Tcl and Tk versions. References toa specific version of Tk assume the corresponding version ofTcl is installed as well.

The Python for macOS installers downloaded from this website dynamicallylink at runtime to Tcl/Tk macOS frameworks. The Tcl/Tk major version isdetermined 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 useexternal Tcl/Tk frameworks so the rest of this section only applies tonon-current releases and, as such, no longer supported.

The Python 64-bit/32-bit macOS installers for Python 3.6.x andand 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 linkerlooks first in /Library/Frameworks for Tcl and Tk frameworks withthe proper major version. This is the standard location for third-partyor 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-suppliedframeworks shipped with macOS. (Note, you should normally not modifyor delete files in /System/Library.)

As is common on macOS, the installed Pythons and the Tcl and Tkframeworks are built to run on multiple CPU architectures (universalbinaries) and across multiple macOS levels (minimum deploymenttarget). For Python to be able to dynamically link with a particularTcl and Tk version, the available architectures in the Tcl/Tk frameworksmust include the architecture that Python is running in and theirminimum deployment target should be no greater than that of Python.

  • 2020-10-05 - updated for 3.9.0 and 3.8.6, remove 2.7
  • 2020-08-17 - updated for 3.7.9
  • 2020-07-20 - updated for 3.8.5
  • 2020-06-27 - updated for 3.7.8
  • 2020-05-14 - updated for 3.8.3
  • 2020-03-10 - updated for 3.8.2 and 3.7.7
  • 2019-12-19 - updated for 3.8.1, 3.7.6, and 2.7.17
  • 2019-10-15 - updated for 3.8.0, 3.7.5, and macOS 10.15
  • 2019-07-08 - updated for 3.7.4; 3.6.x is now security-fix-only
  • 2019-03-25 - updated for 3.7.3
  • 2019-03-03 - updated for 2.7.16
  • 2018-12-24 - updated for 3.7.2 and 3.6.8
  • 2018-10-20 - updated for 3.7.1, 3.6.7, and macOS 10.14
  • 2018-06-27 - updated for 3.7.0 and 3.6.6
  • 2018-05-30 - updated for 3.7.0b5
  • 2018-05-02 - updated for 3.7.0b4 and 2.7.15; removed 32-bit-only refs
  • 2018-03-29 - updated for 3.7.0b3 and 3.6.5
  • 2018-02-28 - updated for 3.7.0b2
  • 2018-01-31 - updated for 3.7.0b1 and 3.6.4
  • 2017-10-03 - updated for 3.6.3 and macOS 10.13
  • 2017-09-16 - updated for 2.7.14; removed 3.5.x
  • 2017-07-17 - updated for 3.6.2
  • 2017-03-21 - updated for 3.6.1 and (belatedly) 3.5.3
  • 2016-12-23 - updated for 3.6.0
  • 2016-12-17 - updated for 2.7.13
  • 2016-09-23 - updated for macOS 10.12
  • 2016-07-31 - updated for 3.5.2 and 2.7.12; removed 3.4.x
  • 2015-12-20 - updated for 3.4.4
  • 2015-12-06 - updated for 3.5.1, 2.7.11, and macOS 10.11
  • 2015-09-13 - updated for 3.5.0
  • 2015-05-23 - updated for 2.7.10 and ActiveTcl 8.5.18.0
  • 2015-02-23 - updated for 3.4.3
  • 2014-12-10 - updated for 2.7.9 and ActiveTcl 8.5.17.0
  • 2014-10-16 - updated for macOS 10.10
  • 2014-10-06 - updated for 3.4.2 and ActiveTcl 8.5.16.0
  • 2014-09-22 - updated for 3.4.2rc1
  • 2014-07-01 - updated for 2.7.8
  • 2014-06-01 - updated for 2.7.7; removed 2.7.6 and 3.3.5
  • 2014-05-18 - updated for 3.4.1 and 2.7.7rc1
  • 2014-03-16 - updated for 3.4.0 and 3.3.5
  • 2014-02-10 - updated for 3.3.4 and 3.4.0rc1
  • 2014-01-05 - updated for 3.4.0b2
  • 2013-11-24 - clarify that the ActiveState website still refers to 8.5.15.0
  • 2013-11-24 - removed built-in for 3.4.0b1, removed 3.3.2 and 2.7.5
  • 2013-11-10 - ActiveTcl 8.5.15.1; removed built-in for 3.3.3rc2 and 2.7.6.
  • 2013-10-27 - updated for 3.3.3rc1 and 2.7.6rc1 and their built-in 8.5.15.
  • 2013-10-24 - updated for macOS 10.9 and ActiveTcl 8.5.15, removed 3.2.5.
  • 2013-10-20 - updated for 3.4.0a4 and its built-in 8.5.15.
  • 2013-09-29 - updated for 3.4.0a3
  • 2013-09-09 - updated for 3.4.0a2 and its built-in 8.5.14.
  • 2013-08-03 - updated for 3.4.0a1 and ActiveTcl 8.4.20
  • 2013-05-18 - updated for ActiveTcl 8.5.14
  • 2013-05-15 - updated for 3.3.2, 2.7.5, and 3.2.5
  • 2013-04-06 - updated for 3.3.1, 2.7.4, and 3.2.4
  • 2012-12-26 - updated for ActiveTcl 8.5.13 and Issue 15853 patch installer
  • 2012-09-29 - updated for 3.3.0 final and reverted to ActiveTcl 8.5.11.1
  • 2012-08-02 - updated for ActiveTcl 8.5.12
  • 2012-07-28 - updated for macOS 10.8
  • 2012-04-11 - updated for 3.2.3 final and 2.7.3 final
  • 2012-03-18 - updated for 3.2.3rc2 and 2.7.3rc2
  • 2012-03-04 - updated for ActiveTcl 8.5.11.1, 3.2.3rc1, 2.7.3rc1, removed 3.1.4
  • 2011-11-12 - updated for ActiveTcl 8.5.11
  • 2011-09-04 - updated for 3.2.2 final
  • 2011-07-21 - updated for macOS 10.7 and ActiveTcl 8.5.10.1
  • 2011-07-09 - updated for 3.2.1 final and ActiveTcl 8.5.10
  • 2011-06-12 - updated for 2.7.2 final and 3.1.4 final
  • 2011-05-30 - updated for 3.2.1rc, 2.7.2rc, and 3.1.4rc
  • 2011-03-08 - add warnings and include details on how Python links with Tcl/Tk releases
  • 2011-02-20 - updated for 3.2 final
  • 2011-01-31 draft 1 - preliminary info for 3.2rc2
  • 2011-01-14 draft 0

In this chapter, you'll get Tk installed on your machine, verify it works, and then see a quickexample of what a Tk program looks like.

Though pretty much all macOS and Linux machines come with Tk installed already, it's often anolder version (typically 8.4.x or an early 8.5). You want to make sure you've got at least version 8.5 (preferably 8.6) to use the new widget set, so if that's not already there, you'll want to install the newer version.

You'll need both Tk and bindings for the language you're using it from. Sometimes these are bundled together, sometimes not. Though there are lots of ways to install Tk, often the easiest is to download and install one of the versions provided by ActiveState (www.activestate.com).

Users of recent Python versions can avoid this intermediate step. Starting with Python 3.7, the binary installers available at python.org now include everything you need to use Tk out of the box.If you're using an earlier Python version, or want to compile it yourself, you'll need to install Tcl/Tk on yoursystem to do so. In this case, ActiveState's distributions are still the recommended way to go.

Remember, this tutorial assumes you're using Python 3, not Python 2. There are some significant differences between the two, including module naming, which is the first thing you'll encounter when trying Tkinter.

ActiveState is a company that sells professional developer tools for dynamic languages. They also provide(for free) quality-controlled distributions of some of these languages, and happen to employa number of core developers of these languages.

Installing Tk on macOS

Install Tk for Python (Tkinter) on macOS

The Easy Way

As noted, the easiest way to get Tk and Tkinter installed on your system is using Python's binary installer,available at python.org. Thanks to work by Python core developer Ned Deily, binaryinstallers starting with version 3.7 include Tcl and Tk.

Remember, we're using Python 3.x here, not 2.x. As of this writing, the latest 3.9 installer (3.9.0rc1) includes Tk 8.6.8.

If, however, you're compiling Python yourself, you'll have more work to do. Read on...

Installing Tcl/Tk

The Tkinter module is included with core Python, of course, but you'll need a version of Tcl/Tk on your system to compile it against. Do yourself a huge favorand get the most recent version.

Whatever you do, do not rely on the Tk versions included in macOS! Older versions included Tk 8.4.x. Even more recent macOS versions include an early 8.5 version (8.5.9, released in 2010), which has several serious bugs that are easily triggered by Tkinter.

While there are several different ways to get Tcl and Tk onto your machine, the easiest and most recommended is to use the ActiveTcl distribution.

In your web browser, visit www.activestate.com/products/activetcl.Download ActiveTcl (as of this writing, it's version 8.6.9). Make sure to download an 8.6.x version, not something older!Note that you will need to create an account with ActiveState (no cost) to download it. After it's downloaded, run the installer to get Tcl and Tk loaded onto your machine.

If you're a masochist and want to read about other Tcl/Tk options and variations and how they interact with Python, see the Mac Tcl/Tk page at python.org If you want to compile Tcl/Tkfrom source, see www.tcl.tk.

Compiling Python

When compiling Python from source, you may need to tell it where to find the ActiveTcl (or other) distribution. Otherwise, it might not find any Tcl/Tk distribution (so Tkinter won't work),or it could find the (ancient and broken) version of Tcl/Tk supplied with macOS.

If you're using Python 3.9 or newer, the build system will look in /Library/Frameworks, where ActiveState and other custom builds are typically installed.

The initial '%' is the Unix shell prompt; you don't have to type it. The rest of it should all go on one line, without adding line breaks.

When compiling Python versions prior to 3.9, you will need to add two new command-line options to the initial ./configure in the Python build process. The first provides the locations of the Tcl and Tk include files, and the second provides the locations of the Tcl and Tk libraries. These are usually found in two different locations (i.e., Tcl.framework and Tk.framework). You therefore need to provide two locations for the include files and two for the libraries. Note the location of the quotes in the command below and the spaces separating the Tcl and Tk paths.

If you have multiple versions of Tcl/Tk installed on your system (and in the same frameworks), you may need to check inside the framework to ensure the most recent version is marked as the current one. If not, you may need to adjust your paths to point to the specific version (i.e., Versions/8.x/) within each framework.

When everything is built, be sure to test it out. Start Python from your terminal, e.g.

This should give you the Python command prompt. From the prompt, enter these two commands:

This should pop up a small window; the first line at the top of the window should say 'This is Tcl/Tk version 8.6'; makesure it is not 8.4 or 8.5!

Install Tkinter Mac Python 3.8

Get an error saying 'No module named tkinter'? You're probably using Python 2. This tutorial assumes Python 3.

You can also get the exact version of Tcl/Tk that is being used with:

It should return something like '8.6.9'.

Verified install using ActiveTcl 8.6.9.8609.2 and Python 3.90rc1 source code from python.org on macOS 10.15.6.

Install Tk for Tcl on macOS

On macOS, the easiest way to get Tk is to install the 'ActiveTcl' distribution from ActiveState, which includes Tcl, Tk, plus a number of other extension libraries.

In your web browser, go to www.activestate.com, and followalong the links to download the Community Edition of ActiveTcl.Note that you will need to create an account with ActiveState (no cost) to download it.Make sure you're downloading an 8.6.x version, not an older version.

Run the installer to get everything loaded onto your machine.When you're done, you'll find a shiny new application called 'Wish 8.6' inside the Utilitiesfolder of your Applications folder. This is the 'wish' shell, an application that includesboth Tcl and Tk.

If you launch that application, you'll see two windows popup (see below), one titled 'Wish' which willcontain your application, and the second titled 'Console' which is where you can type inTcl/Tk commands.


The Wish application running on macOS.

For convenient use from the Unix command line, you'll also find a script installed as/usr/local/bin/wish8.6 which will launch the same application.

To verify the exact version of Tcl/Tk that you are running, from the Wish console type the following:

We want this to be returning something like '8.6.9'.

Verified install using ActiveTcl 8.6.9.8609.2 on macOS 10.15.6.

Install Tk for Ruby (Ruby/Tk) on macOS

While previous versions of macOS included both Ruby and Tk (albeit older 8.4 versions),since Snow Leopard this has no longer been the case.

Ruby/Tk is a binding that links against an existing but separate Tk library. So, to get the latest version of Tk for Ruby, we're going to have to do first download the latest 8.6.x Tcl/Tk version from ActiveState.

Install ActiveTcl

The 'ActiveTcl' distribution from ActiveState contains the latest Tk, as well as the latestversion of Tcl (which Ruby's Tk bindings use internally to talk to Tk). In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActiveTcl. Note that you will need to create an account with ActiveState (no cost) to download it.Again, make sure you're downloading an 8.6.x version.

Run the installer and everything will be loaded onto your machine.

Install Ruby

Next, you'll want to install Ruby. There are multiple ways to do this, as explained at www.ruby-lang.org. One option is to use a package manager like Homebrew. Once it's been installed (at /usr/local/bin/brew) you can install Ruby from a command prompt (e.g. Terminal) via:

The initial '%' is the Unix shell prompt; you don't have to type it.

That should put the Ruby binaries in /usr/local/opt/ruby/bin).You can check this via brew info ruby. Below, where we use gem or irb,make sure you're running the version you just installed. One way to do that is specifying the fullpath.

Install Ruby/Tk

Next, you'll need to download and install Ruby's Tk module, which is packaged as a Ruby gem. To do so, from the command prompt, run:

The Tk gem will look for installed versions of Tcl and Tk in /Library/Frameworks, which is where ActiveTcl puts them.

To verify that everything worked, start up /usr/local/opt/ruby/bin/irb and type:

The first line should load Ruby/Tk; typically if there was a problem with finding Tcl/Tk itwould show up here. The second line will return the version of Tk that you're running,which should be something like '8.6.9'.

Verified install using ActiveTcl 8.6.9.8609.2 and Ruby 2.7.1 via Homebrew on macOS 10.15.6.

Install Tk for Perl (Tkx) on macOS

For modern Tk programming using Perl, the 'Tkx' module is highly recommended, and we'llbe using that here. It links against an existing but separate Tk library. So, to get the latest version of Tk for Perl, we're going to have to do first download the latest 8.6.x Tcl/Tk version from ActiveState.

This tutorial used to rely on the ActivePerl distribution from ActiveState, which bundled a full Tcl/Tk installation, as well as the Tkx module. Unfortunately, as of this writing, there is not a macOS version of ActivePerl available.

Install ActiveTcl

The 'ActiveTcl' distribution from ActiveState contains the latest Tk, as well as the latestversion of Tcl (which Perl's Tk bindings use internally to talk to Tk). In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActiveTcl. Note that you will need to create an account with ActiveState (no cost) to download it.Again, make sure you're downloading an 8.6.x version.

Run the installer and everything will be loaded onto your machine.

Install Perl

Next, you'll want to install Perl. There are multiple ways to do this, as explained at www.perl.org. One option is to use a package manager like Homebrew. Once it's been installed (at /usr/local/bin/brew) you can install Ruby from a command prompt (e.g. Terminal) via:

The initial '%' is the Unix shell prompt; you don't have to type it.

That should put the Perl binaries in /usr/local/opt/perl/bin).You can check this via brew info perl. Below, where we use perl,make sure you're running the version you just installed. One way to do that is specifying the fullpath.

Install Tkx

Next, you'll need to download and install Perl's Tkx module. We can grab it from CPAN. Unfortunately, at present it will not install correctly due to errors in its tests. We can bypass the tests and install it anyway. To do so, from the command prompt, run:

The Tkx module will look for installed versions of Tcl and Tk in /Library/Frameworks, which is where ActiveTcl puts them.

To check that this worked, run this from the Unix command line:

This will return the version of Tcl/Tk that it found. It should be something like '8.6.9'.

Verified install using ActiveTcl 8.6.9.8609.2 and Perl 5.32.0 via Homebrew on macOS 10.15.6.

Installing Tk on Windows

Install Tk for Python (Tkinter) on Windows

Tkinter (and, since Python 3.1, ttk, which is the interface to the newer themed widgets) is included in the Python standard library. We highly recommend installingPython using the standard binary distributions from python.org. These will automatically install Tcl/Tk, which of course, is needed by Tkinter.

If you're instead building Python from source code, the Visual Studio projects included in the 'PCbuild' directorycan automatically fetch and compile Tcl/Tk on your system.

Once you've installed or compiled Python, test it out to make sure Tkinter works. From the Python prompt, enter these two commands:

This should pop up a small window; the first line at the top of the window should say 'This is Tcl/Tk version 8.6'; makesure it is not 8.4 or 8.5!

Get an error saying 'No module named tkinter'? You're probably using Python 2. This tutorial assumes Python 3.

You can also get the exact version of Tcl/Tk that is being used with:

It should return something like '8.6.9'.

Verified using Python 3.9.0rc1 binary installer from python.org (containing Tcl/Tk 8.6.9) on Windows 10 version 1809.

Install Tk for Tcl on Windows

On Windows, the easiest way to get Tcl/Tk onto your machine is to install the 'ActiveTcl' distribution from ActiveState, which includes Tcl, Tk, plus a number of other extension libraries.

In your web browser, go to www.activestate.com, and followalong the links to download the Community Edition of ActiveTcl for Windows. Make sure you're downloading an 8.6.x version. Note that you will need to create an account with ActiveState (no cost) to download it.

Run the installer, and follow along. You'll end up with a fresh installof ActiveTcl, usually located in C:ActiveTcl. From a command prompt,you should then be able to run a Tcl/Tk 8.6 shell via:

This should pop up a small window titled 'wish', which will contain your application. A second, larger windowtitled 'Console' is where you can type in Tcl/Tk commands. To verify the exact version of Tcl/Tk that you are running, type the following:

We want this to be returning something like '8.6.9'.

Type 'exit' in the console window to exit.You may also want to add C:ActiveTclbin to your PATH environment variable.

Verified install using ActiveTcl 8.6.9.8609-2 on Windows 10.

Install Tk for Ruby (Ruby/Tk) on Windows

Ruby/Tk is the binding for Tk. In the distant past, installing it on your Windows machine used to be pure hell, involving installinga separate version of Tcl/Tk, downloading a development environment like Visual Studio, downloading the Rubysource code, carefully compiling Ruby, ...

Luckily, it is now only mildly painful, thanks to the good folks behind RubyInstaller forWindows.

The one-click installer used to include everything you needed to run Ruby/Tk, including the underlying Tcl/Tk libraries. Unfortunately, Tk was removed from the Ruby standard library (stdlib) in version 2.4, and made available as an external gem. RubyInstaller followed suit.

Install ActiveTcl

First, you'll need to install Tcl/Tk.

On Windows, the easiest way to get Tcl/Tk onto your machine is to install the 'ActiveTcl' distribution from ActiveState, which includes Tcl, Tk, plus a number of other extension libraries.

In your web browser, go to www.activestate.com, and followalong the links to download the Community Edition of ActiveTcl for Windows. Make sure you're downloading an 8.6.x version. Note that you will need to create an account with ActiveState (no cost) to download it.

Run the installer, and follow along. You'll end up with a fresh install of ActiveTcl in C:ActiveTcl.

Install Ruby

Next, go to rubyinstaller.org. Download and run the installer,which will install everything into the directory you choose, e.g. C:Ruby26.

Install Ruby/Tk

Next, you'll need to download and install Ruby's Tk module, which is packaged as a Ruby gem. To do so, open a command prompt and run:

Tkinter Python 3 Install Pip Mac

The initial '%' is the Unix shell prompt; you don't have to type it.

Tell Ruby Where to Find ActiveTcl

You're not done yet. If you try to use Tk from Ruby, it will complain that it can't find the underlying Tcl/Tk libraries. We'll need to do a couple of things to fix that.

First, Ruby needs to find the tcl86t.dll and tk86t.dll shared libraries. These are located in C:ActiveTclbin. Make a copy of them somewhere Ruby can find them, e.g. C:Ruby26bin.

Second, the Tcl and Tk shared libraries will look for a bunch of initialization and other scripts which were installed as part of ActiveTcl. The best way to specify where to find them is to set the TCL_LIBRARY and TK_LIBRARY system environment variables.

This can be done in the Windows control panel (or search for 'system environment variables' from the taskbar). In Windows 10, you'll find a button labelled 'Environment Variables...' in the 'Advanced' tab of 'System Properties'. Add these system variables:

If you're running a shell via command prompt you'll need to restart it to see those new additions.

To verify the version of Tk, start up your newly installed copy of 'irb' (which would have beeninstalled in C:Ruby26bin), and type:

The first line should load Ruby/Tk. The second line will return the version of Tk that you're running,which should be something like '8.6.9'.

Install Tkinter Mac Python 3.7

Verified install using ActiveTcl 8.6.9.8609-2, RubyInstaller Ruby+DevKit 2.6.6-1 on Windows 10 version 1809.

Install Tk for Perl (Tkx) on Windows

For modern Tk programming using Perl, the 'Tkx' module is highly recommended, and we'llbe using that here. The easiest way to get set up is to use the 'ActivePerl' distribution from www.activestate.com.

Install Tkinter Mac Python 3.6

The 'ActivePerl' distribution from ActiveState includes not only Perl, but also recent versions ofTk and Tcl (which Tkx uses internally to talk to Tk). In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActivePerl. Note that you will need to create an account with ActiveState (no cost) to download it.

Run the installer and everything will be loaded onto your machine. On our machine, perl.exe was installedat 'C:Perl64bin'

To find out what version of Tk Perl and Tkx are using, run this from the Windows command prompt:

We want this to be returning something like '8.5.13'.

Versions of ActivePerl prior to 5.10 (and some of the first 5.10 builds) included earlier versions of Tcl/Tk (8.4.x rather than 8.5.x). Use a more recent version, and and verify that you do have Tk 8.5 or newer.

Verified install using ActivePerl 5.28 on Windows 10 version 1809.

Installing Tk on Linux

Install Tk for Python (Tkinter) on Linux/X11

Tcl/tk Download Machine

Tkinter (and, since Python 3.1, ttk, which is the interface to the newer themed widgets) is included in the Python standard library. It relies on Tcl/Tk being installed onyour system. Depending on how you install Python, this may not happen automatically.

Install Tkinter Mac Python 32-bit

You have several different options to get Python and Tkinter onto your machine. We'll show you two, using your distro's package manager, or compiling from source.

Option 1. Your Linux Distribution's Package Manager

Currently supported Linux distributions usually install a recent version of Python 3.x by default. If not, they have apackage (.deb, .rpm, etc.) that you can install using their package manager. This is usually the easiest way to installPython.

However, after you're done installing Python, you should verify that Tkinter works correctly. Start up a Python shell (e.g. /usr/bin/python3) and verify the install (see below).

You may find that when you try to import tkinter that you get an error. Sometimes it will tell you that you need to install another package. If so, follow the instructions, and try again. It may also just give you Python's standard error message: 'ModuleNotFoundError: No module named 'tkinter'.

If you're getting an error saying 'No module named tkinter' (without the single quotes around the module name), you're probably using Python 2. This tutorial assumes Python 3.

Sometimes Linux distributions separate out their Tkinter support into a separate package. That saves installing the Tcl/Tk libraries for people who are using Python but not Tkinter. If so, you'll need to find and install this package, which wiil also ensure that an appropriate version of the Tcl/Tk libraries are installed on your system.

For example, running Ubuntu 20.04LTS, Python 3.8.2 is already installed. However, to use Tkinter, you need to install a separate package, named python3-tk:

In this case, that package provides Tcl/Tk 8.6.x libraries to be used with Python.

Option 2. Install Tcl/Tk and Compile the Standard Python Distribution

If you'd like to use the standard source distribution from python.org, you can certainly do that.

But to do so, you'll need to get the Tcl and Tk include files and libraries loaded on your machine first.Again, while there are several ways to do that, the easiest is to download and install ActiveTcl.

Another option would be to install the Tk development package, e.g. tk8.6-dev via your package manager.

In your web browser, go to www.activestate.com/products/activetcl.Download the latest version of ActiveTcl for Linux. Make sure you're downloading an 8.6 or newer version. Note that you will need to create an account with ActiveState (no cost) to download it. After it's downloaded, unpack it, run the installer (sudo ./install.sh), and follow along. You'll end up with a fresh installof ActiveTcl, located in e.g. /opt/ActiveTcl-8.6.

Next, download the current Python 3.x source distribution from python.org, and unpack it.On your configure line, you'll need to tell it how to find the version of Tcl/Tk you installed. Then build as usual:

If you installed tk8.6-dev via your package manager instead of using ActiveTcl, the include files should be found in /usr/include/tcl8.6, and the libraries libtcl8.6.so and libtk8.6.so should be in /usr/lib/x86_64-linux-gnu.

Make sure to verify your install (see below).

Didn't work? There may have been an error compiling Python's tkinter code. To check, from the main Pythonsource directory, try touch Modules/_tkinter.c (note the underscore) and then make to recompile it.Watch closely for error messages.

The most common thing is that the way you specified the Tcl/Tk include and librariesneeds to be changed somehow. Or if you get messages that certain include files can't be found (e.g. X11/Xlib.h) youmay need to install additional packages on your Linux distribution (e.g. apt-get install libx11-dev). Onceyou get it to compile without errors, don't forget to make install.

Verifying your Install

At the Python command prompt, enter these two commands:

This should pop up a small window; the first line at the top of the window should say 'This is Tcl/Tk version 8.6'; makesure it is not 8.4!

If it gives you an error when you try to import tkinter (e.g. 'If this fails your Python may not be configured for Tk'), something hasn't been set up correctly. If you compiled Python yourself, see above to check for compile errors.

Get an error saying 'No module named tkinter'? You're probably using Python 2. This tutorial assumes Python 3.

You can also get the exact version of Tcl/Tk that is being used with:

It should return something like '8.6.9'.

Verified install using ActiveTcl 8.6.9.8609.2 and Python 3.90rc1 source code from python.org on Ubuntu 20.04LTS.

Install Tk for Tcl on Linux/X11

Using a Package Manager

Pretty much all Linux distributions have Tcl/Tk packages available via their package managers, e.g., apt. Usually there are a variety of packages, providing libraries, command-line tools, development options if you're building extensions, and many more. On Ubuntu and many other distributions, apt install tk8.6 should be enough to install /usr/bin/wish8.6, which you'll use to run your Tcl/Tk programs.

Using ActiveTcl

Another option is to install the 'ActiveTcl' distribution from ActiveState, which includes Tcl, Tk, plus a number of other extension libraries.

In your web browser, go to www.activestate.com, and followalong the links to download the Community Edition of ActiveTcl for Linux. Make sure you're downloading an 8.6.x version. Note that you will need to create an account with ActiveState (no cost) to download it.

Unpack it, and run the installer (sudo ./install.sh), and follow along. You'll end up with a fresh installof ActiveTcl, located in /opt/ActiveTcl-8.6. You should then be able to run a Tcl/Tk 8.6 shell via:

This should pop up a window titled 'wish8.6'. To verify the exact version of Tcl/Tk that you are running, from the Wish prompt (in the terminal window) type the following:

We want this to be returning something like '8.6.9'. Type a control-D at the prompt in the terminal windowto exit. You may also want to add /opt/ActiveTcl-8.6/bin to your Unix path.

Verified install using ActiveTcl 8.6.9.8609.2 on Ubuntu 20.04LTS.

Install Tk for Ruby (Ruby/Tk) on Linux/X11

To get Ruby/Tk working on Linux, we'll rely on your distribution's package manager. The package names and commands shown here are for Ubuntu, and may be different on your system.

Because Ruby/Tk is an add-on gem, it needs to be compiled on your system. That means we're going to need to install the development versions of the Tcl/Tk libraries (tk8.6-dev) as well as Ruby (ruby2.7-dev plus ruby2.7 for the command-line tools like irb and gem]). This will also ensure we have the necessary compilers, dependent libraries like X11, and so on.

The initial '%' is the Unix shell prompt; you don't have to type it.

Finally, you can install the Ruby/Tk binding with:

To verify that everything worked, start up irb and type:

The first line should load Ruby/Tk; typically if there was a problem with compiling itwould show up here. The second line will return the version of Tk that you're running,which should be something like '8.6.10'.

Verified install using tk8.6-dev 8.6.10-1, ruby2.7.0 on Ubuntu 20.04LTS.

Install Tk for Perl (Tkx) on Linux/X11

For modern Tk programming using Perl, the 'Tkx' module is highly recommended, and we'llbe using that here. The easiest way to get set up is to use the 'ActivePerl' distribution from www.activestate.com.

The 'ActivePerl' distribution from ActiveState includes not only Perl, but also recent versions ofTk and Tcl (which Tkx uses internally to talk to Tk). In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActivePerl. Note that you will need to create an account with ActiveState (no cost) to download it.

Run the installer and everything will be loaded onto your machine, in e.g. /opt/ActivePerl-5.28.

To find out what version of Tk Perl and Tkx are using, run this from the command line:

We want this to be returning something like '8.5.13'.

Versions of ActivePerl prior to 5.10 (and some of the first 5.10 builds) included earlier versions of Tcl/Tk (8.4.x rather than 8.5.x). Use a more recent version, and and verify that you do have Tk 8.5 or newer.

Verified install using ActivePerl 5.28.1 on Ubuntu 20.04LTS.

The Obligatory First Program

To make sure that everything actually did work, let's try to run a 'Hello World'program in Tk. While for something this short, you could just type it in directlyto the interpreter, instead use your favorite text editor to put it in a file.

Save this to a file named 'hello.py'. From a command prompt, type:

Tcl For Windows

Couldn't find hello.py? You might be looking in the wrong directory. Try providingthe full path to hello.py.

Save this to a file named 'hello.tcl'. From the wish shell, type:

Couldn't find hello.tcl? You might be looking in the wrong directory. You caneither give the full path to hello.tcl, or use Tcl's pwd and cd commands tosee what directory you're in, and change to a different one.

Save this to a file named 'hello.rb'. Start up [tk::inl 'irb'], and from the commandprompt, type:

Couldn't find hello.rb? You might be looking in the wrong directory. You caneither give the full path to hello.rb, or use Ruby's Dir.pwd and Dir.chdir commands tosee what directory you're in, and change to a different one.

Note that there are two underscores between 'ttk' and 'button'.

Save this to a file named 'hello.pl'. From a command prompt, type:

Couldn't find hello.pl? You might be looking in the wrong directory. Try providingthe full path to hello.pl.

Not working? Are you sure you're using an 8.5 or newer version of Tcl/Tk? See the installchapter...


Our first program. Some work left to do before the IPO.

Spotted a mistake? Couldn't find what you were looking for? Suggestions? Let me know!
If you've found this tutorial useful, please check out Modern Tkinter.