Last active
February 27, 2019 19:24
-
-
Save dpineiden/9c969a2a0217a13b39afc4d0c4e13f07 to your computer and use it in GitHub Desktop.
Quamash workin with PySide2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# © 2014 Mark Harviston <[email protected]> | |
# © 2014 Arve Knudsen <[email protected]> | |
# BSD License | |
"""Implementation of the PEP 3156 Event-Loop with Qt.""" | |
__author__ = 'Mark Harviston <[email protected]>, Arve Knudsen <[email protected]>' | |
__version__ = '0.6.1' | |
__url__ = 'https://github.com/harvimt/quamash' | |
__license__ = 'BSD' | |
__all__ = ['QEventLoop', 'QThreadExecutor'] | |
import sys | |
import os | |
import asyncio | |
import time | |
import itertools | |
from queue import Queue | |
from concurrent.futures import Future | |
import logging | |
import importlib | |
logger = logging.getLogger('quamash') | |
try: | |
QtModuleName = os.environ['QUAMASH_QTIMPL'] | |
except KeyError: | |
QtModule = None | |
else: | |
logger.info('Forcing use of {} as Qt Implementation'.format(QtModuleName)) | |
QtModule = importlib.import_module(QtModuleName) | |
if not QtModule: | |
for QtModuleName in ('PyQt5', 'PyQt4', 'PySide', 'PySide2'): | |
try: | |
QtModule = importlib.import_module(QtModuleName) | |
except ImportError: | |
continue | |
else: | |
break | |
else: | |
raise ImportError('No Qt implementations found') | |
logger.info('Using Qt Implementation: {}'.format(QtModuleName)) | |
QtCore = importlib.import_module(QtModuleName + '.QtCore', package=QtModuleName) | |
QtGui = importlib.import_module(QtModuleName + '.QtGui', package=QtModuleName) | |
if QtModuleName == 'PyQt5': | |
from PyQt5 import QtWidgets | |
QApplication = QtWidgets.QApplication | |
else: | |
from PySide2 import QtWidgets | |
QApplication = QtWidgets.QApplication |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment