[Pkg-bitcoin-commits] [python-quamash] 116/269: Fix QApplication usage
Jonas Smedegaard
dr at jones.dk
Fri Nov 24 11:26:22 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository python-quamash.
commit 68a752af888da7ca0e48b9e1d0a4d5c7f1b2d537
Author: Arve Knudsen <arve.knudsen at gmail.com>
Date: Mon Jul 21 16:34:33 2014 +0200
Fix QApplication usage
---
quamash/__init__.py | 23 ++++++++++++-----------
tests/test_qeventloop.py | 4 +---
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/quamash/__init__.py b/quamash/__init__.py
index b17e5c7..5b585b1 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -27,12 +27,12 @@ else:
raise ImportError('No Qt implementations found')
QtCore = __import__(QtModuleName + '.QtCore', fromlist=(QtModuleName,))
-
-try:
- QtGui = __import__(QtModuleName + '.QtWidgets', fromlist=(QtModuleName,))
-except ImportError:
- QtGui = __import__(QtModuleName + '.QtGui', fromlist=(QtModuleName,))
-
+QtGui = __import__(QtModuleName + '.QtGui', fromlist=(QtModuleName,))
+if QtModuleName == 'PyQt5':
+ from PyQt5 import QtWidgets
+ QApplication = QtWidgets.QApplication
+else:
+ QApplication = QtGui.QApplication
if not hasattr(QtCore, 'Signal'):
QtCore.Signal = QtCore.pyqtSignal
@@ -157,10 +157,10 @@ def _easycallback(fn):
>>> import asyncio
>>>
>>> import quamash
- >>> from quamash import QEventLoop, QtCore, QtGui
+ >>> from quamash import QEventLoop, QtCore, QtGui, QApplication
>>> QThread, QObject = quamash.QtCore.QThread, quamash.QtCore.QObject
>>>
- >>> app = QtCore.QCoreApplication.instance() or QtGui.QApplication([])
+ >>> app = QApplication([])
>>>
>>> global_thread = QThread.currentThread()
>>> class MyObject(QObject):
@@ -210,8 +210,8 @@ class QEventLoop(_baseclass):
Implementation of asyncio event loop that uses the Qt Event loop
>>> import quamash, asyncio
- >>> from quamash import QtCore, QtGui
- >>> app = QtCore.QCoreApplication.instance() or QtGui.QApplication([])
+ >>> from quamash import QtCore, QtGui, QApplication
+ >>> app = QApplication([])
>>>
>>> @asyncio.coroutine
... def xplusy(x, y):
@@ -224,7 +224,8 @@ class QEventLoop(_baseclass):
"""
def __init__(self, app=None):
self.__timers = []
- self.__app = app or QtCore.QCoreApplication.instance()
+ self.__app = app or QApplication.instance()
+ assert self.__app is not None, 'No QApplication has been instantiated'
self.__is_running = False
self.__debug_enabled = False
self.__default_executor = None
diff --git a/tests/test_qeventloop.py b/tests/test_qeventloop.py
index 542a0e6..f82a53c 100644
--- a/tests/test_qeventloop.py
+++ b/tests/test_qeventloop.py
@@ -10,8 +10,6 @@ import multiprocessing
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
import socket
-from quamash import QtCore, QtGui
-
import quamash
import pytest
@@ -33,7 +31,7 @@ class _SubprocessProtocol(asyncio.SubprocessProtocol):
@pytest.fixture(scope='session')
def application():
- return QtCore.QCoreApplication.instance() or QtGui.QApplication([])
+ return QApplication.instance() or quamash.QApplication([])
@pytest.fixture
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/python-quamash.git
More information about the Pkg-bitcoin-commits
mailing list