2018-05-01 15:10:37 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-05-01 09:05:04 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2018-05-01 09:27:33 +00:00
|
|
|
from os import path
|
2018-05-01 14:30:56 +00:00
|
|
|
from pathlib import Path
|
2018-05-01 09:05:04 +00:00
|
|
|
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 *
|
|
|
|
|
2018-05-01 14:30:56 +00:00
|
|
|
app = QApplication(sys.argv)
|
|
|
|
app.setApplicationName("SimplePanoramaViewer")
|
|
|
|
|
|
|
|
if len(sys.argv) < 2:
|
2018-09-01 10:43:25 +00:00
|
|
|
img_dialog = QFileDialog.getOpenFileName(None, "Open image", str(Path.home()), "JPG Images (*.jpg *.JPG *.jpeg *.pjpeg *.pjpg *.PJPG)")
|
2018-05-01 14:30:56 +00:00
|
|
|
img = img_dialog[0]
|
|
|
|
else:
|
|
|
|
img = path.abspath(sys.argv[1])
|
|
|
|
|
|
|
|
if img == "":
|
|
|
|
exit(0)
|
2018-05-01 09:05:04 +00:00
|
|
|
|
2018-09-30 15:54:41 +00:00
|
|
|
img = img.replace("\\", "/")
|
2018-09-01 10:19:38 +00:00
|
|
|
img = img.replace("'", "\\'")
|
|
|
|
|
2018-05-01 09:27:33 +00:00
|
|
|
exe_dir = path.dirname(path.realpath(sys.argv[0]))
|
|
|
|
os.chdir(exe_dir)
|
2018-05-01 09:15:07 +00:00
|
|
|
|
2018-05-01 09:05:04 +00:00
|
|
|
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))
|
2018-05-01 09:15:07 +00:00
|
|
|
html = html.replace("__IMG_PATH__", img)
|
2018-05-01 09:05:04 +00:00
|
|
|
|
|
|
|
web = QWebEngineView()
|
2018-09-01 15:06:50 +00:00
|
|
|
url = QUrl.fromLocalFile(exe_dir + "/index.html")
|
|
|
|
web.setHtml(html,url)
|
2018-05-01 09:15:07 +00:00
|
|
|
web.setWindowTitle(img)
|
2018-09-01 10:29:31 +00:00
|
|
|
web.showMaximized()
|
2018-05-01 09:05:04 +00:00
|
|
|
web.show()
|
|
|
|
|
|
|
|
sys.exit(app.exec_())
|