Difference between revisions of "How to install a simple web browser"

[unchecked revision] [quality revision]
m (Display platform)
m
 

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

2 solutions exist:

  • Qt® application
  • Qt® Python™ application


1 qt-wpe-simple-browser[edit]

1.1 Installation[edit]

 apt-get update
 apt-get install qt-wpe-simple-browser

1.2 Usage[edit]

 qt-wpe-simple-browser <url http://>

2 python3-pyqt5[edit]

2.1 Installation[edit]

 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_()

2.2 Usage[edit]

 python3 web_browser.py  <url http://>

3 Display platform[edit]

Two solutions exist to display the web browser:

  • using eglfs
  • using Wayland

3.1 wayland[edit]

  • 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

  • Launch the Python web browser
 qt-wpe-simple-browser <url http://>

or

 python3 web_browser.py  <url http://>

3.2 eglfs[edit]

  • 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
 qt-wpe-simple-browser <url http://>

or

 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'

3.2 wayland[edit]

  • Weston must be started
systemctl start weston@root
  • Install qtwayland
apt-get install qtwayland
  • Set Wayland egl as display platform
export QT_QPA_PLATFORM=wayland-egl
  • Launch the Python web browser
qt-wpe-simple-browser <url http://>

or

python3 web_browser.py <url http://>


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

2 solutions exist:
* Qt<sup>®</sup> application
* Qt<sup>®</sup> Python™ application

==qt-wpe-simple-browser==
===Installation===
 {{Board$}} apt-get update
 {{Board$}} apt-get install qt-wpe-simple-browser
===Usage===
 {{Board$}} qt-wpe-simple-browser <url http://>


==python3-pyqt5==
===Installation===
 {{Board$}} apt-get update
 {{Board$}} apt-get install python3-pyqt5

Create the web_browser.py script:<source lang="python">

# 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_()</source>


===Usage===
 {{Board$}} python3 web_browser.py  <url http://>


==Display platform==
Two solutions exist to display the web browser:
* using eglfs
* using Wayland
{{ReviewsComments|ABO W2050
Wayland is the ST preferred choice. I would suggest to swap the order of the two chapters to give Wayland higher visibility}}
===wayland===
* 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
* Launch the Python web browser
 {{Board$}} qt-wpe-simple-browser <url http://>

or
 {{Board$}} python3 web_browser.py  <url http://>

===eglfs===
* 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$}} qt-wpe-simple-browser <url http://>

or
 {{Board$}} python3 web_browser.py  <url http://>


{{ Info | With HDMI connection, it is advised to use the following kms eglfs_config.json config file in order to avoid cursor rendering issue.<source>

{
  "device": "/dev/dri/card0",
  "hwcursor": false,
  "pbuffers": true,
  "outputs": [
    {
      "name": "HDMI1",
      "mode": "1280x720"
    }
  ]
}</source>


Set Qt variable to use the json config file:<pre>

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

}}
===wayland===
* Weston must be started
 {{Board$}} systemctl start weston@root

{{ReviewsComments|ABO W2050
Weston is supposed started by default. I would change it with "Weston must be started. If you have stopped it, as in the previous chapter, start it with the following command"}}

* Install qtwayland
 {{Board$}} apt-get install qtwayland
* Set Wayland egl as display platform
 {{Board$}} export QT_QPA_PLATFORM=wayland-egl
* Launch the Python web browser
 {{Board$}} qt-wpe-simple-browser <url http://>

or
 {{Board$}} python3 web_browser.py  <url http://>

<noinclude>

[[Category:How to run use cases with expansions]]
{{PublicationRequestId | 18262 | 27Nov'20}}</noinclude>
Line 55: Line 55:
 
* using Wayland
 
* using Wayland
   
{{ReviewsComments|ABO W2050
+
===wayland===
Wayland is the ST preferred choice. I would suggest to swap the order of the two chapters to give Wayland higher visibility}}
+
* 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
  +
* Launch the Python web browser
  +
{{Board$}} qt-wpe-simple-browser <url http://>
  +
or
  +
{{Board$}} python3 web_browser.py  <url http://>
   
 
===eglfs===
 
===eglfs===
Line 91: Line 101:
 
</pre>
 
</pre>
 
}}
 
}}
 
===wayland===
 
* Weston must be started
 
{{Board$}} systemctl start weston@root
 
 
{{ReviewsComments|ABO W2050
 
Weston is supposed started by default. I would change it with "Weston must be started. If you have stopped it, as in the previous chapter, start it with the following command"}}
 
 
* Install qtwayland
 
{{Board$}} apt-get install qtwayland
 
* Set Wayland egl as display platform
 
{{Board$}} export QT_QPA_PLATFORM=wayland-egl
 
* Launch the Python web browser
 
{{Board$}} qt-wpe-simple-browser <url http://>
 
or
 
{{Board$}} python3 web_browser.py  <url http://>
 
   
 
<noinclude>
 
<noinclude>