SimplePanoramaViewer/main.py

33 lines
760 B
Python
Raw Normal View History

#!/usr/bin/env python
import os
import sys
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 *
path = os.path.dirname(os.path.realpath(sys.argv[0]))
os.chdir(path)
img = sys.argv[1]
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://" + path + "/index.html"))
web.setWindowTitle(img)
web.show()
sys.exit(app.exec_())