Axeman
0
Q:

how to use QTWebkit in pyqt5

from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
from flask import Flask, render_template, request

import threading
import sys
import os

# You can copy past this code and run it
# Just change the index.html to your html file

class MainWindow(QMainWindow):
    # In here i've set the QWebEngineView as CentralWidget
    # You can use a layout to position it where you want
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        self.setWindowTitle("Sorted Ware House")
        self.setMinimumSize(900, 550)

        self.path = os.getcwd() # get app folder location
        self.path = self.path.replace('\\', '/') # replace backslash
        self.browser = QWebEngineView() # create web view
        self.browser.setUrl(QUrl(self.path+"/index.html")) # set root
        self.setCentralWidget(self.browser) # place it in QMainWindow

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()

    app.exec_()
# For smooth scrolling add '--enable-smooth-scrolling' parameter when
#  running the app as your app's argument.
# like : python app.py --enable-smooth-scrolling
0

New to Communities?

Join the community