how to use qtwebkit in pyqt5

Solutions on MaxInterview for how to use qtwebkit in pyqt5 by the best coders in the world

showing results for - "how to use qtwebkit in pyqt5"
Lukas
06 Mar 2016
1from PyQt5.QtCore import QUrl
2from PyQt5.QtWidgets import QMainWindow, QApplication
3from PyQt5.QtWebEngineWidgets import QWebEngineView
4from flask import Flask, render_template, request
5
6import threading
7import sys
8import os
9
10# You can copy past this code and run it
11# Just change the index.html to your html file
12
13class MainWindow(QMainWindow):
14    # In here i've set the QWebEngineView as CentralWidget
15    # You can use a layout to position it where you want
16    def __init__(self, *args, **kwargs):
17        super(MainWindow, self).__init__(*args, **kwargs)
18
19        self.setWindowTitle("Sorted Ware House")
20        self.setMinimumSize(900, 550)
21
22        self.path = os.getcwd() # get app folder location
23        self.path = self.path.replace('\\', '/') # replace backslash
24        self.browser = QWebEngineView() # create web view
25        self.browser.setUrl(QUrl(self.path+"/index.html")) # set root
26        self.setCentralWidget(self.browser) # place it in QMainWindow
27
28if __name__ == "__main__":
29    app = QApplication(sys.argv)
30    window = MainWindow()
31    window.show()
32
33    app.exec_()
34# For smooth scrolling add '--enable-smooth-scrolling' parameter when
35#  running the app as your app's argument.
36# like : python app.py --enable-smooth-scrolling