Tkinter is a bridge that connects programmers with tk which is written in python. Tk provides all the graphical widgets, so that it enables us to develop GUI applications. In other words, tkinter is a portable GUI toolkit for python. If you had just migrated from python2 to python3, you might faced some problems when importing tkinter.
$ python3
Python 3.3.2 (default, Jun 30 2014, 17:20:03)
[GCC 4.8.3 20140624 (Red Hat 4.8.3-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'tkinter'
Install tkinter for Python3
In python2, we usually install tkinter
package and it can immediately imported. But we can not do that in python3. So, install python3-tkinter
package to be able to import tkinter.
$ sudo yum install python3-tkinter
Check your tkinter support
Enter an interactive python interpreter in your favorite shell/ terminal.
$ python3
Python 3.3.2 (default, Jun 30 2014, 17:20:03)
[GCC 4.8.3 20140624 (Red Hat 4.8.3-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> tkinter._test()
If this works, it should pop up a small window with two buttons (Click me! and QUIT buttons) and you’re all set. Congratulations!
