In Ubuntu 20.04, when the system is turned on, I want the page to open in window mode for a url I specify myself. I developed a code like the following, but for the url I specify myself, js: SyntaxError: ‘Unaxpected token .’ error. I did not encounter such a problem when I gave any other url. When I tried the same code with the url I specified in Ubuntu 22.04, it worked without any problems. Can you help me? Thanks.
I thought maybe if I changed the versions it would fix it, but it didn’t. the last versions I used are like this
Versions I use
python 3.8.10
PyQt5 5.14.1
PyQtWebEngine 5.14.0
PyQt5-sip 12.13.0
ubuntu 20.04
`
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings
from PyQt5.QtWidgets import QApplication, QMainWindow
class WebViewWindow(QMainWindow):
def __init__(self):
super().__init__()
self.webview = QWebEngineView(self)
self.setCentralWidget(self.webview)
self.setWindowTitle("Web View Example")
self.resize(800, 600)
url = QUrl(" my own url ") # Convert string URL to QUrl object
self.webview.load(url) # Use load method directly, no need for load_url method
if __name__ == "__main__":
app = QApplication([])
window = WebViewWindow()
window.show()
app.exec_()
`
Veysel Üstüntaş is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.