]> Softwares of Agnibho - medscript.git/commitdiff
Patch: Windows webview file path
authorAgnibho Mondal <mondal@agnibho.com>
Thu, 31 Aug 2023 19:51:29 +0000 (01:21 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Thu, 31 Aug 2023 19:51:29 +0000 (01:21 +0530)
renderbox.py
viewbox.py

index aa5b6244111c5b84f06d0dfac2c0aa83695a4c71..124233e6da94b746452911a0618f31f599371fe2 100644 (file)
@@ -9,7 +9,7 @@ from PyQt6.QtWidgets import QMainWindow, QToolBar, QFileDialog
 from PyQt6.QtWebEngineWidgets import QWebEngineView
 from PyQt6.QtGui import QAction
 from PyQt6.QtCore import QUrl
-import webbrowser
+import os, webbrowser
 
 class RenderBox(QMainWindow):
 
@@ -45,7 +45,7 @@ class RenderBox(QMainWindow):
     def update(self, file):
         try:
             self.file=file
-            self.webview.load(QUrl("file://"+self.file))
+            self.webview.load(QUrl("file:///"+self.file.replace(os.sep, "/")))
         except Exception as e:
             QMessageBox.warning(self,"Display failed", "Failed to display file.")
             self.hide()
index af20d813407991fe247e0632b8bec6f0a2486a18..f6fa3d32d92295d875d9168b253da196f7e8c6c9 100644 (file)
@@ -22,4 +22,4 @@ class ViewBox(QMainWindow):
         self.setCentralWidget(self.webview)
 
     def open(self, file):
-        self.webview.load(QUrl("file://"+os.path.abspath(file)))
+        self.webview.load(QUrl("file:///"+os.path.abspath(file).replace(os.sep, "/")))