Registered User (Merge articles) |
Registered User mNo edit summary Tag: 2017 source edit |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 8: | Line 8: | ||
A simple web browser, based on Qt5, can be easily installed using the [[Package repository for OpenSTLinux distribution | package repository for OpenSTLinux distribution]] service. | A simple web browser, based on Qt5, can be easily installed using the [[Package repository for OpenSTLinux distribution | package repository for OpenSTLinux distribution]] service. | ||
Solution: * Qt<sup>®</sup> Python™ application | |||
* Qt<sup>®</sup> Python™ application | |||
==python3-pyqt5== | ==python3-pyqt5== | ||
Line 74: | Line 64: | ||
{{Board$}} export QML2_IMPORT_PATH='/usr/lib/qt5/qml/' | {{Board$}} export QML2_IMPORT_PATH='/usr/lib/qt5/qml/' | ||
* Launch the Python web browser | * Launch the Python web browser | ||
{{Board$}} python3 web_browser.py <url http://> --qwindowgeometry <width>x<height> | {{Board$}} python3 web_browser.py <url http://> --qwindowgeometry <width>x<height> | ||
Line 87: | Line 75: | ||
{{Board$}} export QT_QPA_EGLFS_ALWAYS_SET_MODE='1' | {{Board$}} export QT_QPA_EGLFS_ALWAYS_SET_MODE='1' | ||
* Launch the web browser | * Launch the web browser | ||
{{Board$}} python3 web_browser.py <url http://> | {{Board$}} python3 web_browser.py <url http://> | ||
Latest revision as of 17:20, 12 December 2024
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]
Board $> apt-get update
Board $> 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]
Board $> 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
Board $> systemctl start weston@root
- Install qtwayland
Board $> apt-get install qtwayland
- Set Wayland egl as display platform
Board $> export QT_QPA_PLATFORM=wayland-egl
- And set the following variable
Board $> export QML2_IMPORT_PATH='/usr/lib/qt5/qml/'
- Launch the Python web browser
Board $> python3 web_browser.py <url http://> --qwindowgeometry <width>x<height>
2.2. eglfs[edit | edit source]
- Stop the Weston application
Board $> systemctl stop weston@root
- Set eglfs as display platform
Board $> export QT_QPA_PLATFORM=eglfs
- And set the following variables
Board $> export QML2_IMPORT_PATH='/usr/lib/qt5/qml/'
Board $> export QT_QPA_EGLFS_ALWAYS_SET_MODE='1'
- Launch the web browser
Board $> python3 web_browser.py <url http://>