How To Install Tkinter In Windows
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 either ActivePython 3.8 or 3.7 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.
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:
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.
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.
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.
Use ActivePython and accelerate your Python projects.
- The #1 Python solution used by innovative enterprise teams
- Comes pre-bundled with top Python packages
- Spend less time resolving dependencies and more time on quality coding