Thanks to visit codestin.com
Credit goes to github.com

Skip to content

QtPy vendored fix #653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions winpython/_vendor/qtpy/QtCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
del pyqtSignal, pyqtSlot, pyqtProperty, QT_VERSION_STR
elif PYSIDE2:
from PySide2.QtCore import *
try: # may be limited to PySide-5.11a1 only
from PySide2.QtGui import QStringListModel
except:
pass
elif PYQT4:
from PyQt4.QtCore import *
# Those are things we inherited from Spyder that fix crazy crashes under
Expand Down Expand Up @@ -58,6 +62,7 @@ class QStandardPaths():
HomeLocation = _QDesktopServices.HomeLocation
DataLocation = _QDesktopServices.DataLocation
CacheLocation = _QDesktopServices.CacheLocation
writableLocation = _QDesktopServices.storageLocation

# Those are imported from `import *`
del pyqtSignal, pyqtSlot, pyqtProperty, QT_VERSION_STR, qInstallMsgHandler
Expand Down Expand Up @@ -88,6 +93,7 @@ class QStandardPaths():
HomeLocation = _QDesktopServices.HomeLocation
DataLocation = _QDesktopServices.DataLocation
CacheLocation = _QDesktopServices.CacheLocation
writableLocation = _QDesktopServices.storageLocation

import PySide.QtCore
__version__ = PySide.QtCore.__version__
Expand Down
36 changes: 30 additions & 6 deletions winpython/_vendor/qtpy/QtGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
exposed here. Therefore, you need to treat/use this package as if it were
the ``PyQt5.QtGui`` module.
"""
import warnings

from . import PYQT5, PYQT4, PYSIDE, PYSIDE2, PythonQtError

Expand Down Expand Up @@ -75,10 +76,21 @@
from PyQt4.QtGui import QDesktopServices as _QDesktopServices

class QDesktopServices():
openUrl = _QDesktopServices.openUrl
setUrlHandler = _QDesktopServices.setUrlHandler
unsetUrlHandler = _QDesktopServices.unsetUrlHandler
openUrl = _QDesktopServices.openUrl
setUrlHandler = _QDesktopServices.setUrlHandler
unsetUrlHandler = _QDesktopServices.unsetUrlHandler

def __getattr__(self, name):
attr = getattr(_QDesktopServices, name)

new_name = name
if name == 'storageLocation':
new_name = 'writableLocation'
warnings.warn(("Warning QDesktopServices.{} is deprecated in Qt5"
"we recommend you use QDesktopServices.{} instead").format(name, new_name),
DeprecationWarning)
return attr
QDesktopServices = QDesktopServices()

elif PYSIDE:
from PySide.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
Expand Down Expand Up @@ -126,8 +138,20 @@ class QDesktopServices():
from PySide.QtGui import QDesktopServices as _QDesktopServices

class QDesktopServices():
openUrl = _QDesktopServices.openUrl
setUrlHandler = _QDesktopServices.setUrlHandler
unsetUrlHandler = _QDesktopServices.unsetUrlHandler
openUrl = _QDesktopServices.openUrl
setUrlHandler = _QDesktopServices.setUrlHandler
unsetUrlHandler = _QDesktopServices.unsetUrlHandler

def __getattr__(self, name):
attr = getattr(_QDesktopServices, name)

new_name = name
if name == 'storageLocation':
new_name = 'writableLocation'
warnings.warn(("Warning QDesktopServices.{} is deprecated in Qt5"
"we recommend you use QDesktopServices.{} instead").format(name, new_name),
DeprecationWarning)
return attr
QDesktopServices = QDesktopServices()
else:
raise PythonQtError('No Qt bindings could be found')
24 changes: 24 additions & 0 deletions winpython/_vendor/qtpy/QtHelp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
#
# Copyright © 2009- The Spyder Development Team
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)

"""QtHelp Wrapper."""

import warnings

from . import PYQT5
from . import PYQT4
from . import PYSIDE
from . import PYSIDE2

if PYQT5:
from PyQt5.QtHelp import *
elif PYSIDE2:
from PySide2.QtHelp import *
elif PYQT4:
from PyQt4.QtHelp import *
elif PYSIDE:
from PySide.QtHelp import *
7 changes: 3 additions & 4 deletions winpython/_vendor/qtpy/QtMultimedia.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import warnings

from . import PYQT5
from . import PYQT4
from . import PYSIDE
from . import PYSIDE2


if PYQT5:
from PyQt5.QtMultimedia import *
elif PYSIDE2:
# Current wheels don't have this module
# from PySide2.QtMultimedia import *
pass
from PySide2.QtMultimedia import *
elif PYQT4:
from PyQt4.QtMultimedia import *
from PyQt4.QtGui import QSound
Expand Down
24 changes: 24 additions & 0 deletions winpython/_vendor/qtpy/QtSql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright © 2009- The Spyder Development Team
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
# -----------------------------------------------------------------------------
"""Provides QtSql classes and functions."""

# Local imports
from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError

if PYQT5:
from PyQt5.QtSql import *
elif PYSIDE2:
from PySide2.QtSql import *
elif PYQT4:
from PyQt4.QtSql import *
elif PYSIDE:
from PySide.QtSql import *
else:
raise PythonQtError('No Qt bindings could be found')

del PYQT4, PYQT5, PYSIDE, PYSIDE2
59 changes: 43 additions & 16 deletions winpython/_vendor/qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
**QtPy** is a shim over the various Python Qt bindings. It is used to write
Qt binding indenpendent libraries or applications.

The shim will automatically select the first available API (PyQt5, PyQt4 and
finally PySide).
If one of the APIs has already been imported, then it will be used.

You can force the use of one specific bindings (e.g. if your application is
using one specific bindings and you need to use library that use QtPy) by
setting up the ``QT_API`` environment variable.
Otherwise, the shim will automatically select the first available API (PyQt5,
PySide2, PyQt4 and finally PySide); in that case, you can force the use of one
specific bindings (e.g. if your application is using one specific bindings and
you need to use library that use QtPy) by setting up the ``QT_API`` environment
variable.

PyQt5
=====
Expand Down Expand Up @@ -62,10 +63,23 @@
"""

import os
import sys
import warnings

# Version of QtPy
from ._version import __version__


class PythonQtError(Exception):
"""Error raise if no bindings could be selected"""
pass


class PythonQtWarning(Warning):
"""Warning if some features are not implemented in a binding."""
pass


# Qt API environment variable name
QT_API = 'QT_API'

Expand All @@ -86,23 +100,30 @@

# Setting a default value for QT_API
os.environ.setdefault(QT_API, 'pyqt5')

API = os.environ[QT_API].lower()
initial_api = API
assert API in (PYQT5_API + PYQT4_API + PYSIDE_API + PYSIDE2_API)

is_old_pyqt = is_pyqt46 = False
PYQT5 = True
PYQT4 = PYSIDE = PYSIDE2 = False


class PythonQtError(Exception):
"""Error raise if no bindings could be selected"""
pass
if 'PyQt5' in sys.modules:
API = 'pyqt5'
elif 'PySide2' in sys.modules:
API = 'pyside2'
elif 'PyQt4' in sys.modules:
API = 'pyqt4'
elif 'PySide' in sys.modules:
API = 'pyside'


if API in PYQT5_API:
try:
from PyQt5.Qt import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
from PyQt5.Qt import QT_VERSION_STR as QT_VERSION # analysis:ignore
from PyQt5.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
from PyQt5.QtCore import QT_VERSION_STR as QT_VERSION # analysis:ignore
PYSIDE_VERSION = None
except ImportError:
API = os.environ['QT_API'] = 'pyside2'
Expand All @@ -129,7 +150,7 @@ class PythonQtError(Exception):
sip.setapi('QTextStream', 2)
sip.setapi('QTime', 2)
sip.setapi('QUrl', 2)
except AttributeError:
except (AttributeError, ValueError):
# PyQt < v4.6
pass
from PyQt4.Qt import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
Expand All @@ -153,12 +174,18 @@ class PythonQtError(Exception):
except ImportError:
raise PythonQtError('No Qt bindings could be found')

# If a correct API name is passed to QT_API and it could not be found,
# switches to another and informs through the warning
if API != initial_api:
warnings.warn('Selected binding "{}" could not be found, '
'using "{}"'.format(initial_api, API), RuntimeWarning)

API_NAME = {'pyqt5': 'PyQt5', 'pyqt': 'PyQt4', 'pyqt4': 'PyQt4',
'pyside': 'PySide', 'pyside2':'PySide2'}[API]

if PYQT4:
import sip
try:
API_NAME += (" (API v{0})".format(sip.getapi('QString')))
except AttributeError:
pass
import sip
try:
API_NAME += (" (API v{0})".format(sip.getapi('QString')))
except AttributeError:
pass
31 changes: 19 additions & 12 deletions winpython/_vendor/qtpy/_patch/qheaderview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
import warnings

def introduce_renamed_methods_qheaderview(QHeaderView):

Expand All @@ -15,8 +16,9 @@ def sectionsClickable(self):
return _isClickable(self)
QHeaderView.sectionsClickable = sectionsClickable
def isClickable(self):
raise Exception('isClickable is only available in Qt4. Use '
'sectionsClickable instead.')
warnings.warn('isClickable is only available in Qt4. Use '
'sectionsClickable instead.', stacklevel=2)
return _isClickable(self)
QHeaderView.isClickable = isClickable


Expand All @@ -28,8 +30,9 @@ def sectionsMovable(self):
return _isMovable(self)
QHeaderView.sectionsMovable = sectionsMovable
def isMovable(self):
raise Exception('isMovable is only available in Qt4. Use '
'sectionsMovable instead.')
warnings.warn('isMovable is only available in Qt4. Use '
'sectionsMovable instead.', stacklevel=2)
return _isMovable(self)
QHeaderView.isMovable = isMovable


Expand All @@ -41,8 +44,9 @@ def sectionResizeMode(self, logicalIndex):
return _resizeMode(self, logicalIndex)
QHeaderView.sectionResizeMode = sectionResizeMode
def resizeMode(self, logicalIndex):
raise Exception('resizeMode is only available in Qt4. Use '
'sectionResizeMode instead.')
warnings.warn('resizeMode is only available in Qt4. Use '
'sectionResizeMode instead.', stacklevel=2)
return _resizeMode(self, logicalIndex)
QHeaderView.resizeMode = resizeMode

_setClickable = QHeaderView.setClickable
Expand All @@ -53,8 +57,9 @@ def setSectionsClickable(self, clickable):
return _setClickable(self, clickable)
QHeaderView.setSectionsClickable = setSectionsClickable
def setClickable(self, clickable):
raise Exception('setClickable is only available in Qt4. Use '
'setSectionsClickable instead.')
warnings.warn('setClickable is only available in Qt4. Use '
'setSectionsClickable instead.', stacklevel=2)
return _setClickable(self, clickable)
QHeaderView.setClickable = setClickable


Expand All @@ -66,8 +71,9 @@ def setSectionsMovable(self, movable):
return _setMovable(self, movable)
QHeaderView.setSectionsMovable = setSectionsMovable
def setMovable(self, movable):
raise Exception('setMovable is only available in Qt4. Use '
'setSectionsMovable instead.')
warnings.warn('setMovable is only available in Qt4. Use '
'setSectionsMovable instead.', stacklevel=2)
return _setMovable(self, movable)
QHeaderView.setMovable = setMovable


Expand All @@ -80,8 +86,9 @@ def setSectionResizeMode(self, *args):
_setResizeMode(self, *args)
QHeaderView.setSectionResizeMode = setSectionResizeMode
def setResizeMode(self, *args):
raise Exception('setResizeMode is only available in Qt4. Use '
'setSectionResizeMode instead.')
warnings.warn('setResizeMode is only available in Qt4. Use '
'setSectionResizeMode instead.', stacklevel=2)
_setResizeMode(self, *args)
QHeaderView.setResizeMode = setResizeMode


Expand Down
2 changes: 1 addition & 1 deletion winpython/_vendor/qtpy/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (1, 3, 0)
version_info = (1, 4, 2)
__version__ = '.'.join(map(str, version_info))
35 changes: 0 additions & 35 deletions winpython/_vendor/qtpy/tests/test.ui

This file was deleted.

Loading