Skip to content

Commit bc24a0b

Browse files
committed
Raise an exception if neither backend found
1 parent 3eb04bf commit bc24a0b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/windows/views/timeline_mixins.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,36 @@
2626
"""
2727

2828
import os
29+
import sys
2930
from classes import info
3031
from PyQt5.QtCore import QFileInfo, pyqtSlot, QUrl, Qt, QCoreApplication, QTimer
3132
from PyQt5.QtGui import QCursor, QKeySequence, QColor
3233
from PyQt5.QtWidgets import QMenu
3334
from classes.logger import log
3435
from functools import partial
3536

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)
3646

3747
try:
3848
# Attempt to import QtWebEngine
39-
from PyQt5.QtWebChannel import QWebChannel
4049
from PyQt5.QtWebEngineWidgets import QWebEngineView
50+
from PyQt5.QtWebChannel import QWebChannel
4151
IS_WEBENGINE_VALID = True
4252
except ImportError:
4353
QWebEngineView = object # Prevent inheritance errors
4454
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
5459

5560

5661
class TimelineBaseMixin(object):

0 commit comments

Comments
 (0)