This is a simple panorama viewer based on Photo Sphere Viewer. https://dalan.fr/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SimplePanoramaViewer 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python3
  2. import os
  3. import sys
  4. from os import path
  5. from pathlib import Path
  6. from PyQt5 import QtCore, QtGui, QtWidgets
  7. from PyQt5.QtCore import *
  8. from PyQt5.QtGui import *
  9. from PyQt5.QtWidgets import *
  10. from PyQt5.QtWebEngine import *
  11. from PyQt5.QtWebEngineWidgets import *
  12. app = QApplication(sys.argv)
  13. app.setApplicationName("SimplePanoramaViewer")
  14. if len(sys.argv) < 2:
  15. img_dialog = QFileDialog.getOpenFileName(None, "Open image", str(Path.home()), "JPG Images (*.jpg *.JPG *.jpeg *.pjpeg *.pjpg *.PJPG)")
  16. img = img_dialog[0]
  17. else:
  18. img = path.abspath(sys.argv[1])
  19. if img == "":
  20. exit(0)
  21. img = img.replace("\\", "/")
  22. img = img.replace("'", "\\'")
  23. if getattr( sys, 'frozen', False ) :
  24. exe_dir = path.realpath(sys._MEIPASS)
  25. else :
  26. exe_dir = path.dirname(path.realpath(__file__))
  27. os.chdir(exe_dir)
  28. try:
  29. with open("html/index.html", "r", encoding="utf8") as file:
  30. html = file.read()
  31. except OSError as exception:
  32. print("Error: HTML file not found: " + str(exception))
  33. html = html.replace("__IMG_PATH__", img)
  34. web = QWebEngineView()
  35. url = QUrl.fromLocalFile(exe_dir + "/index.html")
  36. web.setHtml(html,url)
  37. web.setWindowTitle(img)
  38. web.showMaximized()
  39. web.show()
  40. sys.exit(app.exec_())