What is Tkinter?
Tkinter (tk interface) is a Python binding to the Tk GUI toolkit. It's Python's most popular package for building GUI applications and is available on both Windows and Unix systems.
Building a kiosk application
In this example, we'll build a fullscreen application that loads when booting a Raspberry Pi running Raspbian Buster. The application is simple: load a random quote of the day and display it on screen. The full source code is available here:
After cloning the repository, make sure you have all of the dependencies installed by changing to your project directory and running the following command.
cd /path/to/tkinter-quotes python3 -m pip install -r requirements --user
It's also worth noting that Tkinter is not maintained by Python and may need to be installed separately via APT.
sudo apt-get install python3-tk
Once you have all of the required packages, you should be able to run application.py. It consists of a single Gui class that builds the interface and calls an update() method to load a random quote from https://quotes.rest/.
* I'd like to take this moment to say a quick thank you to "They Said So" for making their API available to the public. They have a large collection of data and their Quotes API made it easy to build a quick prototype for this example. Check them out here:theysaidso.com
Assuming you're still in your project directory
will launch the application and you should see the quote on screen. The "Update" button naturally calls the update() method and the "Exit" button quits the application.
Note that if you remove the exit button, the application will not provide any means to the underlying operating system and you will likely have restart your Pi to fix any problems that come your way. Further, if you go through the entire process of loading the application when the Pi boots, future errors may require mounting your drive in another system to fix.
Loading the application on boot
Create a file named quotes.desktop in .config/autostart/ of your home directory. Copy the following contents but be sure to replace the application path with your corresponding home path.
[Desktop Entry] Type=Application Name=Quote of the Day Exec=/usr/bin/python3 /home/pi/tkinter-quotes/application.py
Restart the Pi or logout. The next time you log in, you will be greeted with a fullscreen quote of the day.