|
26 | 26 | """
|
27 | 27 |
|
28 | 28 | import os
|
| 29 | +import sys |
29 | 30 | from classes import info
|
30 | 31 | from PyQt5.QtCore import QFileInfo, pyqtSlot, QUrl, Qt, QCoreApplication, QTimer
|
31 | 32 | from PyQt5.QtGui import QCursor, QKeySequence, QColor
|
32 | 33 | from PyQt5.QtWidgets import QMenu
|
33 | 34 | from classes.logger import log
|
34 | 35 | from functools import partial
|
35 | 36 |
|
| 37 | +try: |
| 38 | + # Attempt to import QtWebKit |
| 39 | + from PyQt5.QtWebKitWidgets import QWebView |
| 40 | + IS_WEBKIT_VALID = True |
| 41 | +except ImportError as ex: |
| 42 | + QWebView = object # Prevent inheritance errors |
| 43 | + IS_WEBKIT_VALID = False |
| 44 | + if sys.platform == "win32": |
| 45 | + log.error("Need PyQt5.QtWebKit on Win32!", exc_info=1) |
36 | 46 |
|
37 | 47 | try:
|
38 | 48 | # Attempt to import QtWebEngine
|
39 |
| - from PyQt5.QtWebChannel import QWebChannel |
40 | 49 | from PyQt5.QtWebEngineWidgets import QWebEngineView
|
| 50 | + from PyQt5.QtWebChannel import QWebChannel |
41 | 51 | IS_WEBENGINE_VALID = True
|
42 | 52 | except ImportError:
|
43 | 53 | QWebEngineView = object # Prevent inheritance errors
|
44 | 54 | IS_WEBENGINE_VALID = False
|
45 |
| - |
46 |
| -try: |
47 |
| - # Attempt to import QtWebKit |
48 |
| - from PyQt5.QtWebKitWidgets import QWebView, QWebPage |
49 |
| - IS_WEBKIT_VALID = True |
50 |
| -except ImportError: |
51 |
| - QWebView = object # Prevent inheritance errors |
52 |
| - QWebPage = object |
53 |
| - IS_WEBKIT_VALID = False |
| 55 | + if not IS_WEBKIT_VALID: |
| 56 | + # Raise the exception, if we have _neither_ backend |
| 57 | + log.error("Missing PyQt5.QtWebEngine (or PyQt5.QtWebKit on Win32)") |
| 58 | + raise |
54 | 59 |
|
55 | 60 |
|
56 | 61 | class TimelineBaseMixin(object):
|
|
0 commit comments