Computers, Laptops & Tablets Accessories & Hardware 30 30 people found this article helpful Make Simple GUIs With the Raspberry Pi Using EasyGUI By Richard Saville Writer Richard Saville is a former Lifewire writer and computer enthusiast who has invented several add-on boards for Raspberry Pi and has been published in MagPi and other outlets. our editorial process Facebook Twitter Richard Saville Updated November 23, 2019 Accessories & Hardware Raspberry Pi Keyboards & Mice Monitors Cards HDD & SSD Printers & Scanners Tweet Share Email Adding a graphical user interface (GUI) to your Raspberry Pi project is a great way to include a screen for data entry, on-screen buttons for controls or even just a smarter way to show readings from components such as sensors. 01 of 10 Make an Interface for Your Project There are a number of different GUI methods available for the Raspberry Pi, however, most have a steep learning curve. The Tkinter Python interface may be the default "go-to" option for most, however, beginners can struggle with its complexity. Similarly, the PyGame library offers options for making impressive interfaces but may be surplus to requirements. If you're looking for a simple and quick interface for your project, EasyGUI could be the answer. What it lacks in graphical beauty it more than makes up for in its simplicity and ease of use. This article will give you an introduction to the library, including some of the most useful options we've found. 02 of 10 Downloading and Importing EasyGUI For this article, we're using the standard Raspbian operating system. Installing the library will be a familiar process to most, using the "apt-get install" method. You'll need an internet connection on your Raspberry Pi, using either a wired Ethernet or WiFi connection. Open a terminal window (the icon of a black screen on your Pi's taskbar) and enter the following command: This command will download the library and install it for you, and that's all the setup you need to do. 03 of 10 Import EasyGUI EasyGUI needs to be imported into a script before you can use its functions. This is achieved by entering a single line at the top of your script and is the same regardless of which EasyGUI interface options you use. Create a new script by entering the following command in your terminal window: A blank screen will appear — this is your empty file (nano is simply the name of a text editor). To import EasyGUI into your script, enter the following line: We use this specific version of the import to make coding even easier later on. For example, when importing this way, instead of having to write 'easygui.msgbox' we can simply use "msgbox." Now let's cover some of the key interface options within EasyGUI. 04 of 10 Basic Message Box This "message box," in its simplest form, gives the user a line of text and a single button to click. Here's an example to try — enter the following line after your import line, and save using Ctrl+X: To run the script, use the following command: You should see a message box appear, with I am a Message Box written in the top bar, and Cool box huh? above the button. 05 of 10 Continue or Cancel Box Sometimes you will need the user to confirm an action or choose whether or not to continue. The "ccbox" box offers the same line of text as the basic message box above, but provides 2 buttons — Continue and Cancel. Here's an example of one in use, with the continue and cancel buttons printing to the terminal. You could change the action after each button press to do whatever you like: from easygui import *import timemsg = "Would you like to continue?"title = "Continue?"if ccbox(msg, title): # show a Continue/Cancel dialog print "User selected continue" # Add other commands here else: # user chose Cancel print "User cancelled" # Add other commands here 06 of 10 Custom Button Box If the built-in box options aren't quite giving you what you need, you can create a custom button box using the "buttonbox" feature. This is great if you have more options that need covering, or perhaps are controlling a number of LEDs or other components with the UI. Here's an example selecting sauce for an order: from easygui import *import time msg = "Which sauce would you like?"choices = ["Mild","Hot","Extra Hot"]reply = buttonbox(msg, choices=choices) if reply == "Mild": print replyif reply == "Hot": print replyif reply == "Extra Hot": print reply 07 of 10 Choice Box Buttons are great, but for long lists of options, a "choice box" makes a lot of sense. These boxes list the available options in rows one after another, with an OK and Cancel box to the side. They're reasonably smart, sorting the options alphabetically and also allowing you to press a key to jump to the first option of that letter. Here's an example showing ten names, which you can see has been sorted in the screenshot. from easygui import *import timemsg ="Who let the dogs out?"title = "Missing Dogs"choices = ["Alex", "Cat", "Michael", "James", "Albert", "Phil", "Yasmin", "Frank", "Tim", "Hannah"]choice = choicebox(msg, title, choices) 08 of 10 Data Entry Box Forms are a great way to capture data for your project, and EasyGUI has a 'multenterbox' option that allows you to show labeled fields to capture information with. Once again it's a case of labeling fields and simply capturing the input. We 've made an example below for a very simple gym membership sign-up form. There are options to add validation and other advanced features, which the EasyGUI website covers in detail. from easygui import *import timemsg = "Member Information"title = "Gym Membership Form"fieldNames = ["First Name","Surname","Age","Weight"]fieldValues =  # the starting valuesfieldValues = multenterbox(msg,title, fieldNames)print fieldValues 09 of 10 Adding Images You can add images to your EasyGUI interfaces by including a very small amount of code. Save an image to your Raspberry Pi in the same directory as your EasyGUI script and make a note of the file name and extension (for example, image1.png). Let's use the button box as an example: from easygui import *import timeimage = "RaspberryPi.jpg"msg = "Is this a Raspberry Pi?"choices = ["Yes","No"]reply = buttonbox(msg, image=image, choices=choices)if reply == "Yes": print "Yes"else: print "No" 10 of 10 More Advanced Features We've covered the main "basic" EasyGUI options here to get you started, however, there are lots more box options and examples available depending on how much you want to learn, and what your project requires. Password boxes, code boxes, and even file boxes are available to name a few. It's a very versatile library that's easy to pick up in minutes, with some great hardware control possibilities as well. If you'd like to learn how to code other things like Java, HTML or more, you can see the best online coding resources available.