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.
GUI Framework with licensing, expiration date and no option to distribute complete app other users? So… thank you, but no.
How can I install pysimplegui on raspberry pi 4. I am not able to install it
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??
reference and cookbook menus no longer exist on the website…what gives ?
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.
🎉🎉🎉 awesome video, keep it up.
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.
Im still learning but could you use this with OpenPLC on an RPi?
Hello, just some feedback. You should include links and code within the description.
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.
is there a place to download your code?
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.
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?
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!
How do you preview pi camera image in gui box?
This is awesome! I would like to create something similar to this. I could add different options right to the GUI?
PiSimpleGUI looks just as easy to use as Qt. Not sure why someone would use it instead of Qt, which is much more powerful.
Thank you……Great
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?
Is this also possible for the RasberyPi pico ?