Tkinter is the de facto way in Python to create Graphical User Interfaces (GUIs). Installing Tkinter on Windows is as simple as installing Python 3.x since Tkinter is included in the Python 3 core.
However, if you want to take advantage of the latest version of Tkinter, you’ll need to install a version of Python that supports Tcl/Tk 8.5 or greater, as well as Ttk (Tile extension integrated into Tk), which is required in order to run the current Tk widget set.
- Python 3.7 or greater for Windows comes with everything you need to run Tk fully configured out-of-the-box.
- If you have Python 3.6 or an earlier version, you can simply upgrade to a newer Python version that includes the latest version of Tkinter.
Python Distributions with Tkinter
Popular Python distributions like ActivePython and Anaconda both come with Tkinter.
The simplest method to install Tkinter in a Windows environment is to download and install ActivePython 3.8 from here.
Alternatively, you can create and activate a Conda environment with Python 3.7 or greater that is integrated with the latest version of Tkinter.
1. To create a new Conda Python environment named <env_name> and install python 3.8, open an Anaconda Prompt or terminal and enter:
$ conda create --name <env_name> python=3.8
2. To activate the new environment that has Python 3.8, and switch to it, enter:
$ activate <env_name>
Verify Tkinter Installation
To verify whether Tkinter is installed ready to be loaded by Python, run the following code in a Python console:
>>> import tkinter >>> tkinter._test()
If Tkinter is installed and working correctly, a small popup window will appear. The first line at the top of the window should state, This is Tcl/Tk version 8.6.
Watch video demonstration here.
You can also verify the Tcl/Tk version used by Tkinter with the following code:
>>> import tkinter >>> tkinter.Tcl().eval('info patchlevel')
The output should be similar to:
>>> '8.6.9'
You can also run a test script to make sure that Tkinter is functioning correctly. For example:
>>> from tkinter import * >>> root = Tk() >>> test = Label(root, text="<message>") >>> test.pack() >>> root.mainloop()
If Tkinter is correctly installed, a small popup window displaying a message should appear.
Next steps
Now that you have installed Tkinter for Windows, start creating your GUI applications by learning how you can position your buttons:
With deep roots in open source, and as a founding member of the Python Foundation, ActiveState actively contributes to the Python community. We offer the convenience, security and support that your enterprise needs while being compatible with the open source distribution of Python.
Download ActivePython Community Edition to get started or contact us to learn more about using ActivePython in your organization.
You can also start by trying our mini ML runtime for Linux or Windows that includes most of the popular packages for Machine Learning and Data Science, pre-compiled and ready to for use in projects ranging from recommendation engines to dashboards.
Related Links
Frequently Asked Questions
How do I install Tkinter on Windows?
Tkinter requires a version of the Tcl programming language. As such, the easiest way to install Tkinter on Windows is by installing a Python distribution such as ActivePython, which bundles both Tcl and Tkinter.
Download ActivePython with Tcl and Tkinter included.
Where can I download Tkinter for Python?
Tkinter requires a version of the Tcl programming language. As such, the easiest way to download Tkinter is by installing a Python distribution such as ActivePython, which bundles both Tcl and Tkinter. Alternatively, tkinter is included in the Python standard library for Python 3.7 and above.
How do I call Tkinter in Python?
If you have Tcl and Tkinter installed on your system, you can run the following command to verify you can start working with it:import tkinter
tkinter._test()
How do I know if Tkinter is installed on Windows?
To see if tkinter is installed correctly on your Windows system, run the following script:from tkinter import *
root = Tk()
test = Label(root, text="")
test.pack()
root.mainloop()
If Tkinter is correctly installed, a small popup window displaying a message should appear.