Quick Note: Web-View with PyQt5 and Qt 5.7+ on Raspberry Pi
This is a short note how to use QtWebKit with Qt 5.7+ on Raspberry Pi.
I was looking at numerous ways of creating a GUI on Raspberry Pi using Python. I did a lot with pygame, but reached a dead end when I wanted to use a touchscreen with gestures. Kivy is often recommended, but I could not get it to work with Stretch (and I am not the only one…). Many other GUI frameworks were painfully slow on a Raspberry Pi version 1 or 2. Others were just no longer actively developed. I ended up with Qt – which works surprisingly well and fast, offers a huge amount of functionality, and – nice! – offers QtCreator – a graphical editor to create the GUI. The UI files can be converted to python easily by using
1 |
pyuic5 [your_name].ui > [your_name].py |
I found Qt not easy to start with, but after getting a grasp of the concepts, it’s really powerful.
I hit a minor obstacle when I wanted to display a webpage within the GUI. Many tutorials tell you to use QtWebKit – but it is deprecated since Qt 5.6. They tell you to use QtWebEngine instead. However, it just does not exist for Raspberry/ARM! Fortunately WebKit is still available – just run
1 |
sudo apt-get install python3-pyqt5.qtwebkit |
and everything works.