SimplePanoramaViewer/SimplePanoramaViewer

34 lines
798 B
Plaintext
Raw Normal View History

#!/usr/bin/env python
import os
import sys
from os import path
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngine import *
from PyQt5.QtWebEngineWidgets import *
img = path.abspath(sys.argv[1])
exe_dir = path.dirname(path.realpath(sys.argv[0]))
os.chdir(exe_dir)
try:
with open("html/index.html", "r", encoding="utf8") as file:
html = file.read()
except OSError as exception:
print("Error: HTML file not found: " + str(exception))
html = html.replace("__IMG_PATH__", img)
app = QApplication(sys.argv)
app.setApplicationName("SimplePanoramaViewer")
web = QWebEngineView()
web.setHtml(html,QUrl("file://" + exe_dir + "/index.html"))
web.setWindowTitle(img)
web.show()
sys.exit(app.exec_())