From 59b5f8088b6a078d738cf89101674c116f89245c Mon Sep 17 00:00:00 2001 From: Taka Date: Mon, 16 Jul 2018 12:03:00 +0000 Subject: [PATCH] Stop PyQt from using cached JS files. --- vasl_templates/main_window.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vasl_templates/main_window.py b/vasl_templates/main_window.py index b8bcd0a..7136661 100644 --- a/vasl_templates/main_window.py +++ b/vasl_templates/main_window.py @@ -1,7 +1,7 @@ """ Main application window. """ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel -from PyQt5.QtWebEngineWidgets import QWebEngineView +from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile, QWebEnginePage from PyQt5.QtGui import QDesktopServices from PyQt5.QtCore import QUrl @@ -28,9 +28,13 @@ class MainWindow( QWidget ): layout = QVBoxLayout( self ) if not webapp.config.get( "DISABLE_WEBENGINEVIEW" ): # load the webapp - browser = QWebEngineView() - layout.addWidget( browser ) - browser.setUrl( QUrl(url) ) + # NOTE: We create an off-the-record profile to stop the view from using cached JS files :-/ + view = QWebEngineView() + layout.addWidget( view ) + profile = QWebEngineProfile( None, view ) + page = QWebEnginePage( profile, view ) + view.setPage( page ) + view.load( QUrl(url) ) else: label = QLabel() label.setText( "Running the {} application.\n\nClose this window when you're done.".format( APP_NAME ) )