Creating a Fullscreen Raspberry Pi GUI (HMI) with PySimpleGUI

Posted by


In this tutorial, we will guide you step by step in creating a fullscreen Raspberry Pi GUI (HMI) using PySimpleGUI. PySimpleGUI is a simple and easy to use Python GUI library that allows you to create desktop applications with minimal effort. With PySimpleGUI, you can quickly create graphical user interfaces for your Raspberry Pi projects.

To get started, make sure you have Python installed on your Raspberry Pi. You can check if Python is installed by running the following command in the terminal:

python --version

If Python is not installed, you can install it by running the following command:

sudo apt-get install python3

Next, you will need to install the PySimpleGUI library. You can do this by running the following command:

pip install PySimpleGUI

Now that you have Python and PySimpleGUI installed, you can start creating your fullscreen GUI. We will create a simple GUI with a single button that displays a message when clicked.

import PySimpleGUI as sg

layout = [[sg.Button('Click me')]]

window = sg.Window('Fullscreen GUI', layout, fullscreen=True)

while True:
    event, values = window.read()

    if event == sg.WIN_CLOSED:
        break

    if event == 'Click me':
        sg.popup('Hello, World!')

window.close()

In this code, we first import the PySimpleGUI library and create a layout with a single button labeled ‘Click me’. We then create a fullscreen window using the sg.Window function with the fullscreen=True parameter.

We then enter a loop where we read events from the window using window.read(). If the event is the window being closed, we break out of the loop and close the window. If the event is the button being clicked, we display a popup message saying ‘Hello, World!’.

Save the code into a file (e.g., fullscreen_gui.py) and run it using the following command:

python fullscreen_gui.py

You should see a fullscreen GUI window with a button that displays a message when clicked.

You can customize the GUI further by adding more elements such as text boxes, sliders, checkboxes, etc., and by defining more complex layouts. PySimpleGUI provides a wide range of elements that you can use to create rich and interactive GUIs for your Raspberry Pi projects.

By following this tutorial, you can easily create a fullscreen Raspberry Pi GUI using PySimpleGUI and enhance the user interface of your projects. Feel free to explore the PySimpleGUI documentation for more advanced features and customization options.

0 0 votes
Article Rating
31 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@DrFailov
1 month ago

GUI Framework with licensing, expiration date and no option to distribute complete app other users? So… thank you, but no.

@salomonbeneitoliva6714
1 month ago

How can I install pysimplegui on raspberry pi 4. I am not able to install it

@cstrombone
1 month ago

What did you actually show us? I don't understand the purpose of this video. You kind of missed the most crucial part: Installing PySimpleGUI on raspberry pi. Like, as far as I can find it is not possible to do. So how did you do it and why didn't you think to add that into a DIY video??

@Adralba007
1 month ago

reference and cookbook menus no longer exist on the website…what gives ?

@matt-on5yl
1 month ago

You have just freed me. You’ve helped me solve my month long problem in python. For that, I am forever grateful. You’re amazing.

@soalersystem123
1 month ago

🎉🎉🎉 awesome video, keep it up.

@ClericChris
1 month ago

This gentleman wins the award for "most amount of accents heard in the 1st 15 seconds of talking" Norwegian, no Australian, wait no that's German, no British, no that's definitely some version of Nordic, wait is that Canadian or American? Oh no it's Polish maybe. Damn wait that's American, maybe Canadian. Honesty I'm still not sure. I'm 90% it's American but there's something else in there when he's in front of the camera.

@bceng89
1 month ago

Im still learning but could you use this with OpenPLC on an RPi?

@HyperionBadger
1 month ago

Hello, just some feedback. You should include links and code within the description.

@saulwarren9611
1 month ago

awsome, Hi, can I install PySimpleGUI onto a pyboard and interact with the GUI with a touchscreen? i want to work on a project that involves creating an RC transmitter to control a RC device.

@warham4155
1 month ago

is there a place to download your code?

@glasscapsule
1 month ago

OMG what did they do to the demo files on github? They should have visual examples so you can see what's what. Couldn't find the example from above for Pi. Does anyone have example code that works on a pi like the one above? Thx.

@operonfun5911
1 month ago

Hello there! Amazing video! Very useful! I've just one question: Which Raspberry did you use? Could it be done with a Zero or a Zero 2 W? I mean, which is the minimum Pi model you need to develop this?

@ivanrojas1475
1 month ago

Hi, I'm a student of Engineering, I just want to thank you for your efforts in explaining everything and put comments in every line of the code, I had no idea how to programm anything for a project I'm doing. They gave less than 3 months to finish a GUI on raspberry and you were my savior!!! Thank you so much!

@nickgama1594
1 month ago

How do you preview pi camera image in gui box?

@Luis-jz2cj
1 month ago

This is awesome! I would like to create something similar to this. I could add different options right to the GUI?

@FRDETsdfs
1 month ago

PiSimpleGUI looks just as easy to use as Qt. Not sure why someone would use it instead of Qt, which is much more powerful.

@mohsenmazandarani7506
1 month ago

Thank you……Great

@trusssrod
1 month ago

I copied your code off the video, typed in and checked about a hundred times. When I run the program from Thonny, the relay button is red, tuns green when I click it, but when I click to turn it off it stays green. I haven't wired it up yet, but I'm assuming the relay LED would turn on with the first click and not turn off when clicked again. Everything else functions as expected. Any ideas?

@LikeWoz
1 month ago

Is this also possible for the RasberyPi pico ?