Python 3.x
If you're using a recent version of Python 3, say version 3.6 or 3.7, then the tkinter module is preloaded. So you can move on to the next tutorial.Python 2.7
However, if you're using Python 2.7 then you might need to install the Tkinter
module.
To check if it's already installed open a new Python interactive session, then enter this statement (making sure there's an uppercase T in Tkinter):
>>> import Tkinter
Did you see an ImportError: No module named Tkinter error message?
If the answer is yes then follow the installation steps below (which are applicable to the Raspbian Jessie distro or the older Raspbian Wheezy image).
Ensure your Raspberry Pi is connected to the Internet, open an LXTerminal window and enter this command:
sudo apt-get install python-tk
If prompted enter the your login password, and reply y to any prompts.
Now we're ready to create GUI apps.
A post from my Learn Python on the Raspberry Pi tutorial.