Skip to content

Instantly share code, notes, and snippets.

@dpineiden
Last active February 27, 2019 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpineiden/9c969a2a0217a13b39afc4d0c4e13f07 to your computer and use it in GitHub Desktop.
Save dpineiden/9c969a2a0217a13b39afc4d0c4e13f07 to your computer and use it in GitHub Desktop.
Quamash workin with PySide2
# © 2014 Mark Harviston <mark.harviston@gmail.com>
# © 2014 Arve Knudsen <arve.knudsen@gmail.com>
# BSD License
"""Implementation of the PEP 3156 Event-Loop with Qt."""
__author__ = 'Mark Harviston <mark.harviston@gmail.com>, Arve Knudsen <arve.knudsen@gmail.com>'
__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