Last edited 2 weeks ago

How to install a simple web browser

Applicable for STM32MP15x lines

Warning DB.png Important
The simple web browser, subject of this article, is not part of STM32MPU ecosystem releases, for which ST provides some support.
This article only provides, as example, some helper guidelines (tips): you may need to make some adaptations depending on your system setup.

A simple web browser, based on Qt5, can be easily installed using the package repository for OpenSTLinux distribution service.

Solution: * Qt® Python™ application

1. python3-pyqt5[edit | edit source]

1.1. Installation[edit | edit source]

 apt-get update
 apt-get install python3-pyqt5

Create the web_browser.py script:

# web_browser.py
# Copyright (c) STMicroelectronics
# License: BSD-3-Clause
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebKitWidgets import *

import sys

class MainWindow(QMainWindow):

    def __init__(self, *args, **kwargs):
        super(MainWindow,self).__init__(*args, **kwargs)

        self.setWindowTitle(sys.argv[1])
        self.browser = QWebView()
        self.browser.setUrl( QUrl(sys.argv[1]) )
        self.setCentralWidget(self.browser)
        self.show()

QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
app = QApplication(sys.argv)
window = MainWindow()
app.exec_()

1.2. Usage[edit | edit source]

 python3 web_browser.py  <url http://>

2. Display platform[edit | edit source]

Two solutions exist to display the web browser:

  • using eglfs
  • using Wayland

2.1. wayland[edit | edit source]

  • Weston must be started. If you have stopped it, you can restart Weston with the following command
 systemctl start weston@root
  • Install qtwayland
 apt-get install qtwayland
  • Set Wayland egl as display platform
 export QT_QPA_PLATFORM=wayland-egl
  • And set the following variable
 export QML2_IMPORT_PATH='/usr/lib/qt5/qml/'
  • Launch the Python web browser
 python3 web_browser.py  <url http://> --qwindowgeometry <width>x<height>

2.2. eglfs[edit | edit source]

  • Stop the Weston application
 systemctl stop weston@root
  • Set eglfs as display platform
 export QT_QPA_PLATFORM=eglfs
  • And set the following variables
 export QML2_IMPORT_PATH='/usr/lib/qt5/qml/'
 export QT_QPA_EGLFS_ALWAYS_SET_MODE='1'
  • Launch the web browser
 python3 web_browser.py  <url http://>
Info white.png Information
With HDMI connection, it is advised to use the following kms eglfs_config.json config file in order to avoid cursor rendering issue.
{
  "device": "/dev/dri/card0",
  "hwcursor": false,
  "pbuffers": true,
  "outputs": [
    {
      "name": "HDMI1",
      "mode": "1280x720"
    }
  ]
}

Set Qt variable to use the json config file:

Board $> export QT_QPA_EGLFS_KMS_CONFIG='/home/root/eglfs_config.json'