use qtpy directly instead of using fallback-PyQt5
This commit is contained in:
parent
aa9edcba2e
commit
4cd0df7299
|
@ -216,8 +216,7 @@ autodoc_mock_imports = [
|
||||||
'pkg_resources',
|
'pkg_resources',
|
||||||
'pycanberra',
|
'pycanberra',
|
||||||
'pyopencl',
|
'pyopencl',
|
||||||
'PyQt4',
|
'qtpy',
|
||||||
'PyQt5',
|
|
||||||
'qrcode',
|
'qrcode',
|
||||||
'stem',
|
'stem',
|
||||||
'xdg',
|
'xdg',
|
||||||
|
|
|
@ -16,7 +16,7 @@ import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from sqlite3 import register_adapter
|
from sqlite3 import register_adapter
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets, QtNetwork
|
from qtpy import QtCore, QtGui, QtWidgets, QtNetwork
|
||||||
|
|
||||||
import dialogs
|
import dialogs
|
||||||
import helper_addressbook
|
import helper_addressbook
|
||||||
|
@ -1442,7 +1442,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self._theme_player = get_plugin('notification.sound', 'theme')
|
self._theme_player = get_plugin('notification.sound', 'theme')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt5 import QtMultimedia
|
from qtpy import QtMultimedia
|
||||||
self._player = QtMultimedia.QSound.play
|
self._player = QtMultimedia.QSound.play
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_plugin = get_plugin(
|
_plugin = get_plugin(
|
||||||
|
|
|
@ -6,7 +6,7 @@ Dialogs that work with BM address.
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from PyQt5 import QtGui, QtWidgets
|
from qtpy import QtGui, QtWidgets
|
||||||
|
|
||||||
import queues
|
import queues
|
||||||
import widgets
|
import widgets
|
||||||
|
|
|
@ -6,7 +6,7 @@ used in `.dialogs.NewChanDialog`.
|
||||||
|
|
||||||
from Queue import Empty
|
from Queue import Empty
|
||||||
|
|
||||||
from PyQt5 import QtGui
|
from qtpy import QtGui
|
||||||
|
|
||||||
from addresses import decodeAddress, addBMIfNotPresent
|
from addresses import decodeAddress, addBMIfNotPresent
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
from PyQt5 import QtCore
|
from qtpy import QtCore
|
||||||
|
|
||||||
qt_resource_data = "\
|
qt_resource_data = "\
|
||||||
\x00\x00\x03\x66\
|
\x00\x00\x03\x66\
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# pylint: skip-file
|
# pylint: skip-file
|
||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from qtpy import QtCore, QtGui, QtWidgets
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from foldertree import AddressBookCompleter
|
from foldertree import AddressBookCompleter
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from qtpy import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
import widgets
|
import widgets
|
||||||
from addresses import addBMIfNotPresent
|
from addresses import addBMIfNotPresent
|
||||||
|
|
|
@ -3,7 +3,7 @@ All dialogs are available in this module.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
from PyQt5 import QtWidgets
|
from qtpy import QtWidgets
|
||||||
|
|
||||||
import paths
|
import paths
|
||||||
import widgets
|
import widgets
|
||||||
|
|
|
@ -6,7 +6,7 @@ Folder tree and messagelist widgets definitions.
|
||||||
|
|
||||||
from cgi import escape
|
from cgi import escape
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from qtpy import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from qtpy import QtCore, QtWidgets
|
||||||
|
|
||||||
import paths
|
import paths
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""The MessageCompose class definition"""
|
"""The MessageCompose class definition"""
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from qtpy import QtCore, QtWidgets
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ text rendering, HTML sanitization, lazy rendering (as you scroll down),
|
||||||
zoom and URL click warning popup.
|
zoom and URL click warning popup.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from qtpy import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
from safehtmlparser import SafeHTMLParser
|
from safehtmlparser import SafeHTMLParser
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env python2.7
|
from qtpy import QtCore, QtWidgets
|
||||||
from PyQt5 import QtCore, QtWidgets
|
|
||||||
|
|
||||||
class MigrationWizardIntroPage(QtWidgets.QWizardPage):
|
class MigrationWizardIntroPage(QtWidgets.QWizardPage):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -4,7 +4,7 @@ Network status tab widget definition.
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from qtpy import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
import l10n
|
import l10n
|
||||||
import network.stats
|
import network.stats
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
NewChanDialog class definition
|
NewChanDialog class definition
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from qtpy import QtCore, QtWidgets
|
||||||
|
|
||||||
import widgets
|
import widgets
|
||||||
from addresses import addBMIfNotPresent
|
from addresses import addBMIfNotPresent
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from PyQt5 import QtWidgets
|
from qtpy import QtWidgets
|
||||||
|
|
||||||
import widgets
|
import widgets
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from qtpy import QtCore, QtGui, QtWidgets
|
||||||
import six
|
import six
|
||||||
|
|
||||||
import debug
|
import debug
|
||||||
|
|
|
@ -4,7 +4,7 @@ src/settingsmixin.py
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from qtpy import QtCore, QtWidgets
|
||||||
|
|
||||||
|
|
||||||
class SettingsMixin(object):
|
class SettingsMixin(object):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from PyQt5 import QtWidgets
|
from qtpy import QtWidgets
|
||||||
|
|
||||||
|
|
||||||
class BMStatusBar(QtWidgets.QStatusBar):
|
class BMStatusBar(QtWidgets.QStatusBar):
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Queue
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from qtpy import QtCore, QtWidgets
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
import bitmessageqt
|
import bitmessageqt
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5 import QtCore
|
from qtpy import QtCore
|
||||||
|
|
||||||
import queues
|
import queues
|
||||||
from network.node import Peer
|
from network.node import Peer
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt5 import QtGui
|
from qtpy import QtGui
|
||||||
|
|
||||||
import state
|
import state
|
||||||
from addresses import addBMIfNotPresent
|
from addresses import addBMIfNotPresent
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from PyQt5 import uic
|
from qtpy import uic
|
||||||
import os.path
|
import os.path
|
||||||
import paths
|
import paths
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,8 @@ PACKAGES = {
|
||||||
"description":
|
"description":
|
||||||
"You only need qtpy if you want to use the GUI."
|
"You only need qtpy if you want to use the GUI."
|
||||||
" When only running as a daemon, this can be skipped.\n"
|
" When only running as a daemon, this can be skipped.\n"
|
||||||
"Also maybe you need to install PyQt5 if your package manager"
|
"Also maybe you need to install PyQt5 or PyQt4"
|
||||||
" not installs it as qtpy dependency"
|
" if your package manager not installs it as qtpy dependency"
|
||||||
},
|
},
|
||||||
"msgpack": {
|
"msgpack": {
|
||||||
"OpenBSD": "py-msgpack",
|
"OpenBSD": "py-msgpack",
|
||||||
|
@ -381,34 +381,47 @@ def check_curses():
|
||||||
def check_pyqt():
|
def check_pyqt():
|
||||||
"""Do pyqt dependency check.
|
"""Do pyqt dependency check.
|
||||||
|
|
||||||
Here we are checking for PyQt4 with its version, as for it require
|
Here we are checking for qtpy with its version, as for it require
|
||||||
PyQt 4.8 or later.
|
PyQt 4.8 or later.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
try:
|
try:
|
||||||
from fallback import PyQt5
|
import qtpy
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.error(
|
logger.error(
|
||||||
'PyBitmessage requires PyQt5 or qtpy, PyQt 4.8 or later'
|
'PyBitmessage requires qtpy, and PyQt5 or PyQt4, '
|
||||||
' and Qt 4.7 or later.')
|
' PyQt 4.8 or later and Qt 4.7 or later.')
|
||||||
PyQt5 = None
|
|
||||||
|
|
||||||
if not PyQt5:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
logger.info('PyQt Version: %s', PyQt5.PYQT_VERSION)
|
from qtpy import QtCore
|
||||||
logger.info('Qt Version: %s', PyQt5.QT_VERSION)
|
try:
|
||||||
|
logger.info('PyQt Version: %s', QtCore.PYQT_VERSION_STR)
|
||||||
|
except AttributeError:
|
||||||
|
logger.info('Can be PySide..')
|
||||||
|
try:
|
||||||
|
logger.info('Qt Version: %s', QtCore.__version__)
|
||||||
|
except AttributeError:
|
||||||
|
# Can be PySide..
|
||||||
|
pass
|
||||||
passed = True
|
passed = True
|
||||||
if version.LooseVersion(PyQt5.PYQT_VERSION) < '4.8':
|
try:
|
||||||
|
if version.LooseVersion(QtCore.PYQT_VERSION_STR) < '4.8':
|
||||||
logger.error(
|
logger.error(
|
||||||
'This version of PyQt is too old. PyBitmessage requries'
|
'This version of PyQt is too old. PyBitmessage requries'
|
||||||
' PyQt 4.8 or later.')
|
' PyQt 4.8 or later.')
|
||||||
passed = False
|
passed = False
|
||||||
if version.LooseVersion(PyQt5.QT_VERSION) < '4.7':
|
except AttributeError:
|
||||||
|
# Can be PySide..
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
if version.LooseVersion(QtCore.__version__) < '4.7':
|
||||||
logger.error(
|
logger.error(
|
||||||
'This version of Qt is too old. PyBitmessage requries'
|
'This version of Qt is too old. PyBitmessage requries'
|
||||||
' Qt 4.7 or later.')
|
' Qt 4.7 or later.')
|
||||||
passed = False
|
passed = False
|
||||||
|
except AttributeError:
|
||||||
|
# Can be PySide..
|
||||||
|
pass
|
||||||
return passed
|
return passed
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,46 +30,3 @@ else:
|
||||||
if data:
|
if data:
|
||||||
hasher.update(data)
|
hasher.update(data)
|
||||||
return hasher
|
return hasher
|
||||||
|
|
||||||
try:
|
|
||||||
import PyQt5
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import qtpy as PyQt5
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
from PyQt5 import QtCore
|
|
||||||
|
|
||||||
QtCore.Signal = QtCore.pyqtSignal
|
|
||||||
PyQt5.PYQT_VERSION = QtCore.PYQT_VERSION_STR
|
|
||||||
PyQt5.QT_VERSION = QtCore.QT_VERSION_STR
|
|
||||||
# try:
|
|
||||||
# from qtpy import QtCore, QtGui, QtWidgets, QtNetwork, uic
|
|
||||||
# except ImportError:
|
|
||||||
# PyQt5 = 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
|
|
||||||
# PyQt5 = types.ModuleType(
|
|
||||||
# 'PyQt5', 'qtpy based dynamic fallback for PyQt5')
|
|
||||||
# PyQt5.__dict__.update(context)
|
|
||||||
# sys.modules['PyQt5'] = PyQt5
|
|
||||||
|
|
|
@ -42,10 +42,7 @@ Returns an instance of :class:`QPixmap` which have generated identicon image.
|
||||||
|
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
|
|
||||||
try:
|
from qtpy import QtCore, QtGui
|
||||||
from PyQt5 import QtCore, QtGui
|
|
||||||
except (ImportError, RuntimeError):
|
|
||||||
from PyQt4 import QtCore, QtGui
|
|
||||||
|
|
||||||
|
|
||||||
class IdenticonRendererBase(object):
|
class IdenticonRendererBase(object):
|
||||||
|
|
|
@ -4,7 +4,7 @@ import atexit
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt5 import QtGui, QtWidgets
|
from qtpy import QtGui, QtWidgets
|
||||||
from xvfbwrapper import Xvfb
|
from xvfbwrapper import Xvfb
|
||||||
from pybitmessage import qidenticon
|
from pybitmessage import qidenticon
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
18
src/tr.py
18
src/tr.py
|
@ -15,26 +15,10 @@ 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 PyQt5 # noqa:F401
|
from qtpy import QtWidgets, QtCore
|
||||||
from PyQt5 import QtWidgets, QtCore
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_translate = _tr_dummy
|
_translate = _tr_dummy
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
from PyQt5 import API
|
|
||||||
except ImportError:
|
|
||||||
API = 'pyqt5'
|
|
||||||
if API == 'pyqt5':
|
|
||||||
_translate = QtWidgets.QApplication.translate
|
_translate = QtWidgets.QApplication.translate
|
||||||
else:
|
|
||||||
def _translate(context, text, disambiguation=None, n=None):
|
|
||||||
return (
|
|
||||||
QtWidgets.QApplication.translate(
|
|
||||||
context, text, disambiguation)
|
|
||||||
if n is None else
|
|
||||||
QtWidgets.QApplication.translate(
|
|
||||||
context, text, disambiguation,
|
|
||||||
QtCore.QCoreApplication.CodecForTr, n)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
_translate = _tr_dummy
|
_translate = _tr_dummy
|
||||||
|
|
Reference in New Issue
Block a user