PyQt5 based qtpy fallback
This commit is contained in:
parent
f4eae01886
commit
973ef47549
|
@ -145,7 +145,7 @@ def createSupportMessage(myapp):
|
||||||
opensslversion = "%s (Python internal), %s (external for PyElliptic)" % (
|
opensslversion = "%s (Python internal), %s (external for PyElliptic)" % (
|
||||||
ssl.OPENSSL_VERSION, OpenSSL._version)
|
ssl.OPENSSL_VERSION, OpenSSL._version)
|
||||||
|
|
||||||
qtapi = os.environ['QT_API']
|
qtapi = os.environ.get('QT_API', 'fallback')
|
||||||
|
|
||||||
frozen = "N/A"
|
frozen = "N/A"
|
||||||
if paths.frozen:
|
if paths.frozen:
|
||||||
|
|
|
@ -3,6 +3,8 @@ Utility functions to check the availability of dependencies
|
||||||
and suggest how it may be installed
|
and suggest how it may be installed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# flake8: noqa:E402
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Only really old versions of Python don't have sys.hexversion. We don't
|
# Only really old versions of Python don't have sys.hexversion. We don't
|
||||||
|
@ -365,9 +367,13 @@ def check_pyqt():
|
||||||
PyQt 4.8 or later.
|
PyQt 4.8 or later.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
qtpy = try_import(
|
try:
|
||||||
'qtpy',
|
from fallback import qtpy
|
||||||
'PyBitmessage requires qtpy, PyQt 4.8 or later and Qt 4.7 or later.')
|
except ImportError:
|
||||||
|
logger.error(
|
||||||
|
'PyBitmessage requires qtpy, PyQt 4.8 or later and Qt 4.7 or later.'
|
||||||
|
)
|
||||||
|
qtpy = None
|
||||||
|
|
||||||
if not qtpy:
|
if not qtpy:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -30,3 +30,36 @@ else:
|
||||||
if data:
|
if data:
|
||||||
hasher.update(data)
|
hasher.update(data)
|
||||||
return hasher
|
return hasher
|
||||||
|
|
||||||
|
try:
|
||||||
|
import qtpy
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
from PyQt5 import QtCore, QtGui, QtWidgets, QtNetwork, uic
|
||||||
|
except ImportError:
|
||||||
|
qtpy = None
|
||||||
|
else:
|
||||||
|
import sys
|
||||||
|
import types
|
||||||
|
|
||||||
|
QtCore.Signal = QtCore.pyqtSignal
|
||||||
|
context = {
|
||||||
|
'API': 'pyqt5', # for tr
|
||||||
|
'PYQT_VERSION': QtCore.PYQT_VERSION_STR,
|
||||||
|
'QT_VERSION': QtCore.QT_VERSION_STR,
|
||||||
|
'QtCore': QtCore,
|
||||||
|
'QtGui': QtGui,
|
||||||
|
'QtWidgets': QtWidgets,
|
||||||
|
'QtNetwork': QtNetwork,
|
||||||
|
'uic': uic
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
from PyQt5 import QtTest
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
context['QtTest'] = QtTest
|
||||||
|
qtpy = types.ModuleType(
|
||||||
|
'qtpy', 'PyQt5 based dynamic fallback for qtpy')
|
||||||
|
qtpy.__dict__.update(context)
|
||||||
|
sys.modules['qtpy'] = qtpy
|
||||||
|
|
|
@ -12,6 +12,7 @@ def _tr_dummy(context, text, disambiguation=None, n=None):
|
||||||
|
|
||||||
if state.enableGUI and not state.curses:
|
if state.enableGUI and not state.curses:
|
||||||
try:
|
try:
|
||||||
|
from fallback import qtpy # noqa:F401
|
||||||
from qtpy import QtWidgets, QtCore, API
|
from qtpy import QtWidgets, QtCore, API
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_translate = _tr_dummy
|
_translate = _tr_dummy
|
||||||
|
|
Loading…
Reference in New Issue
Block a user