0

I've setup a basic PyQt5 GUI window, with a QWebEngine web browser element in the centre, and I'd like a good way to go about setting up the following:

I'd like the web browser to show a local HTML file, and when you press a certain button on the page, it will call a python function, which will in turn update some content in the html.

this is what I've got so far; I've tried a lot of different methods but all of them seemed to be for PyQt4 and not using QWebEngine.

import sys, os
import PyQt5
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import *


class WindowC(PyQt5.QtWidgets.QMainWindow):

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

        self.directory = os.getcwd()

        self.browser = QWebEngineView()
        self.setCentralWidget(self.browser)

        local_url = QUrl.fromLocalFile( os.path.join( self.directory, "page.html" ) )
        self.browser.load(local_url)


app = PyQt5.QtWidgets.QApplication(sys.argv)
window = WindowC()
window.show()
app.exec_()

Sorry if the question's a bit vague

  • Hey, if your questiin is just about connecting python to javascript, then ```zerorpc``` is a very good choice. But the thing is that you need to bind the programs on a socket. See it [here](https://www.zerorpc.io/) – Vipul Tyagi Jul 06 '20 at 00:10
  • I'm trying to have a window with an html file embedded, and have python interact with that html document, basically trying to use PyQT5 with an HTML document so I can use html, js and css with a python back-end – Machinebuilder Jul 06 '20 at 08:07

0 Answers0