[Python-modules-commits] [python-qtpy] 01/05: Imported Upstream version 1.0~b1
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sat Feb 27 13:22:46 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository python-qtpy.
commit 8767b2f2616c41bfe1069cdaefb2d4081cb60fa3
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date: Fri Feb 26 19:00:23 2016 +0000
Imported Upstream version 1.0~b1
---
.gitignore | 36 +++++++
.travis.yml | 71 +++++++++++++
AUTHORS.md | 11 ++
CHANGELOG.rst | 0
CONTRIBUTING.rst | 0
LICENSE.txt | 22 ++++
README.md | 38 +++++++
RELEASE.md | 25 +++++
conda.recipe/build.sh | 3 +
conda.recipe/meta.yaml | 28 +++++
docs/index.md | 0
qtpy/QtCore.py | 45 ++++++++
qtpy/QtDesigner.py | 25 +++++
qtpy/QtGui.py | 108 ++++++++++++++++++++
qtpy/QtNetwork.py | 29 ++++++
qtpy/QtPrintSupport.py | 32 ++++++
qtpy/QtSvg.py | 27 +++++
qtpy/QtTest.py | 36 +++++++
qtpy/QtWebKit.py | 30 ++++++
qtpy/QtWidgets.py | 98 ++++++++++++++++++
qtpy/__init__.py | 129 +++++++++++++++++++++++
qtpy/_version.py | 2 +
qtpy/compat.py | 196 +++++++++++++++++++++++++++++++++++
qtpy/py3compat.py | 261 +++++++++++++++++++++++++++++++++++++++++++++++
qtpy/widgets/__init__.py | 0
setup.cfg | 2 +
setup.py | 90 ++++++++++++++++
tests/README.md | 0
tests/__init__.py | 0
tests/travis.py | 10 ++
30 files changed, 1354 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cc3fb2b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,36 @@
+# Python compiled files
+*.py[ocd]
+
+# C extensions
+*.so
+
+# Kate
+.directory
+
+# PyPi configuration
+.pypirc
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+lib
+lib64
+
+# Translations
+*.mo
+
+# Gedit files
+*~
+
+# Other files
+toread.md
+
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..915b93a
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,71 @@
+language: python
+sudo: false
+
+env:
+ global:
+ - MINCONDA_VERSION="latest"
+ - MINCONDA_LINUX="Linux-x86_64"
+ - MINCONDA_OSX="MacOSX-x86_64"
+matrix:
+ include:
+ # Linux
+ - python: "2.7"
+ env: USE_QT_API=PyQt5
+ os: linux
+ - python: "2.7"
+ env: USE_QT_API=PyQt4
+ os: linux
+ - python: "2.7"
+ env: USE_QT_API=PySide
+ os: linux
+ - python: "3.4"
+ env: USE_QT_API=PyQt4
+ os: linux
+ - python: "3.5"
+ env: USE_QT_API=PyQt5
+ os: linux
+ - python: "3.5"
+ env: USE_QT_API=PyQt4
+ os: linux
+before_install:
+ - "export DISPLAY=:99.0"
+ - "sh -e /etc/init.d/xvfb start"
+install:
+ # Define the value to download
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
+ MINCONDA_OS=$MINCONDA_LINUX;
+ elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
+ MINCONDA_OS=$MINCONDA_OSX;
+ fi
+ # You may want to periodically update this, although the conda update
+ # conda line below will keep everything up-to-date. We do this
+ # conditionally because it saves us some downloading if the version is
+ # the same.
+ - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
+ wget "http://repo.continuum.io/miniconda/Miniconda-$MINCONDA_VERSION-$MINCONDA_OS.sh" -O miniconda.sh;
+ else
+ wget "http://repo.continuum.io/miniconda/Miniconda3-$MINCONDA_VERSION-$MINCONDA_OS.sh" -O miniconda.sh;
+ fi
+ - bash miniconda.sh -b -p $HOME/miniconda
+ - export PATH="$HOME/miniconda/bin:$PATH"
+ - hash -r
+ - conda config --set always_yes yes --set changeps1 no
+ - conda update -q conda
+ # Useful for debugging any issues with conda
+ - conda info -a
+
+ # Test environments for different Qt bindings
+ - if [[ "$USE_QT_API" == "PyQt5" ]]; then
+ conda config --add channels spyder-ide;
+ conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION qt5 pyqt5;
+ elif [[ "$USE_QT_API" == "PyQt4" ]]; then
+ conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION qt pyqt;
+ elif [[ "$USE_QT_API" == "PySide" ]]; then
+ conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION qt pyside;
+ fi
+ - source activate test-environment
+ - python setup.py install
+before_script:
+ - cd tests
+script:
+ - python travis.py
diff --git a/AUTHORS.md b/AUTHORS.md
new file mode 100644
index 0000000..d59ba80
--- /dev/null
+++ b/AUTHORS.md
@@ -0,0 +1,11 @@
+Maintainer
+==========
+
+Gonzalo Peña-Castellanos ([@goanpeca](http://github.com/goanpeca))
+
+Main Authors
+============
+
+* Colin Duquesnoy ([@ColinDuquesnoy](http://github.com/ColinDuquesnoy))
+
+* [The Spyder Development Team](https://github.com/spyder-ide/spyder/graphs/contributors)
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..e69de29
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..e69de29
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..4152f52
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Gonzalo Peña-Castellanos
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1422c27
--- /dev/null
+++ b/README.md
@@ -0,0 +1,38 @@
+QtPy: Abtraction layer for PySide/PyQt4/PyQt5
+---------------------------------------------
+
+**QtPy** (pronounced *'cutie pie'*) is a small abstraction layer that lets you
+write applications using a single api call to either PyQt or PySide. **QtPy**
+also provides a set of additional QWidgets.
+
+It provides support for PyQt5, PyQt4 and PySide using the PyQt5 layout (where
+the QtGui module has been split into QtGui and QtWidgets).
+
+Basically, you write your code as if you were using PyQt5 but import qt from
+``qtpy`` instead of ``PyQt5``.
+
+Attribution and acknowledgements
+--------------------------------
+
+This project is based on the **[pyqode.qt](https://github.com/pyQode/pyqode.qt)** project and the *[spyderlib.qt](https://github.com/spyder-ide/spyder/tree/master/spyderlib/qt)*
+module from the **[spyder](https://github.com/spyder-ide/spyder)** project.
+
+Unlike **pyqode.qt** this is not a namespace package so it is not *tied*
+to a particular project, or namespace.
+
+License
+-------
+
+This project is licensed under the MIT license.
+
+Requirements
+------------
+You need *PyQt5* or *PyQt4* or *PySide* installed on your system to make use
+of QtPy.
+
+Installation
+------------
+
+```bash
+pip install qtpy
+```
diff --git a/RELEASE.md b/RELEASE.md
new file mode 100644
index 0000000..6274c93
--- /dev/null
+++ b/RELEASE.md
@@ -0,0 +1,25 @@
+To release a new version of qtpy on PyPI:
+
+* Install `twine`
+
+```python
+pip install twine
+```
+
+* Update `_version.py` (set release version, remove 'dev')
+
+```python
+git add .
+git commit -m 'comment'
+twine upload dist/*
+git tag -a vX.X.X -m 'comment'
+```
+
+* Update `_version.py` (add 'dev' and increment minor)
+
+```python
+git add .
+git commit -m 'comment'
+git push
+git push --tags
+```
diff --git a/conda.recipe/build.sh b/conda.recipe/build.sh
new file mode 100644
index 0000000..2981b57
--- /dev/null
+++ b/conda.recipe/build.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+$PYTHON setup.py install --single-version-externally-managed --root=/
diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml
new file mode 100644
index 0000000..e48641b
--- /dev/null
+++ b/conda.recipe/meta.yaml
@@ -0,0 +1,28 @@
+package:
+ name: qtpy
+ version: {{ environ.get('GIT_DESCRIBE_TAG') }}
+
+source:
+ git_url: ../
+ git_tag: {{ environ.get('GIT_DESCRIBE_TAG') }}
+
+build:
+ noarch_python: True
+
+requirements:
+ build:
+ - python
+ - setuptools
+ run:
+ - python
+
+test:
+ imports:
+ - qtpy
+ requires:
+ - pyqt
+
+about:
+ home: https://github.com/spyder-ide/qtpy
+ license: MIT
+ summary: Provides an uniform layer to support PyQt4, PyQt5 and PySide with a single codebase
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..e69de29
diff --git a/qtpy/QtCore.py b/qtpy/QtCore.py
new file mode 100644
index 0000000..8667ba3
--- /dev/null
+++ b/qtpy/QtCore.py
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014-2015 Colin Duquesnoy
+# Copyright © 2009- The Spyder Development Team
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides QtCore classes and functions.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PYSIDE_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtCore import *
+ from PyQt5.QtCore import pyqtSignal as Signal
+ from PyQt5.QtCore import pyqtSlot as Slot
+ from PyQt5.QtCore import pyqtProperty as Property
+ from PyQt5.QtCore import QT_VERSION_STR as __version__
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.QtCore import *
+ from PyQt4.QtCore import QCoreApplication
+ from PyQt4.QtCore import Qt
+ from PyQt4.QtCore import pyqtSignal as Signal
+ from PyQt4.QtCore import pyqtSlot as Slot
+ from PyQt4.QtCore import pyqtProperty as Property
+ from PyQt4.QtGui import (QItemSelection, QItemSelectionRange,
+ QSortFilterProxyModel)
+ from PyQt4.QtCore import QT_VERSION_STR as __version__
+elif os.environ[QT_API] in PYSIDE_API:
+ from PySide.QtCore import *
+ from PySide.QtGui import (QItemSelection, QItemSelectionRange,
+ QSortFilterProxyModel)
+ import PySide.QtCore
+ __version__ = PySide.QtCore.__version__
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/QtDesigner.py b/qtpy/QtDesigner.py
new file mode 100644
index 0000000..fc7bd8c
--- /dev/null
+++ b/qtpy/QtDesigner.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014-2015 Colin Duquesnoy
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides QtDesigner classes and functions.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtDesigner import *
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.QtDesigner import *
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/QtGui.py b/qtpy/QtGui.py
new file mode 100644
index 0000000..2b2d3d9
--- /dev/null
+++ b/qtpy/QtGui.py
@@ -0,0 +1,108 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014-2015 Colin Duquesnoy
+# Copyright © 2009- The Spyder Development Team
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides QtGui classes and functions.
+.. warning:: Only PyQt4/PySide QtGui classes compatible with PyQt5.QtGui are
+ exposed here. Therefore, you need to treat/use this package as if it were
+ the ``PyQt5.QtGui`` module.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PYSIDE_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtGui import *
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.Qt import QKeySequence, QTextCursor
+ from PyQt4.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
+ QBrush, QClipboard, QCloseEvent, QColor,
+ QConicalGradient, QContextMenuEvent, QCursor,
+ QDesktopServices, QDoubleValidator, QDrag,
+ QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent,
+ QDropEvent, QFileOpenEvent, QFocusEvent, QFont,
+ QFontDatabase, QFontInfo, QFontMetrics,
+ QFontMetricsF, QGlyphRun, QGradient, QHelpEvent,
+ QHideEvent, QHoverEvent, QIcon, QIconDragEvent,
+ QIconEngine, QImage, QImageIOHandler, QImageReader,
+ QImageWriter, QInputEvent, QInputMethodEvent,
+ QKeyEvent, QLinearGradient,
+ QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2,
+ QMatrix3x3, QMatrix3x4, QMatrix4x2, QMatrix4x3,
+ QMatrix4x4, QMouseEvent, QMoveEvent, QMovie,
+ QPaintDevice, QPaintEngine, QPaintEngineState,
+ QPaintEvent, QPainter, QPainterPath,
+ QPainterPathStroker, QPalette, QPen, QPicture,
+ QPictureIO, QPixmap, QPixmapCache, QPolygon,
+ QPolygonF, QQuaternion, QRadialGradient, QRawFont,
+ QRegExpValidator, QRegion, QResizeEvent,
+ QSessionManager, QShortcutEvent, QShowEvent,
+ QStandardItem, QStandardItemModel, QStaticText,
+ QStatusTipEvent, QSyntaxHighlighter, QTabletEvent,
+ QTextBlock, QTextBlockFormat, QTextBlockGroup,
+ QTextBlockUserData, QTextCharFormat,
+ QTextDocument, QTextDocumentFragment,
+ QTextDocumentWriter, QTextFormat, QTextFragment,
+ QTextFrame, QTextFrameFormat, QTextImageFormat,
+ QTextInlineObject, QTextItem, QTextLayout,
+ QTextLength, QTextLine, QTextList, QTextListFormat,
+ QTextObject, QTextObjectInterface, QTextOption,
+ QTextTable, QTextTableCell, QTextTableCellFormat,
+ QTextTableFormat, QTouchEvent, QTransform,
+ QValidator, QVector2D, QVector3D, QVector4D,
+ QWhatsThisClickedEvent, QWheelEvent,
+ QWindowStateChangeEvent, qAlpha, qBlue,
+ qFuzzyCompare, qGray, qGreen, qIsGray, qRed, qRgb,
+ qRgba)
+elif os.environ[QT_API] in PYSIDE_API:
+ from PySide.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
+ QBrush, QClipboard, QCloseEvent, QColor,
+ QConicalGradient, QContextMenuEvent, QCursor,
+ QDesktopServices, QDoubleValidator, QDrag,
+ QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent,
+ QDropEvent, QFileOpenEvent, QFocusEvent, QFont,
+ QFontDatabase, QFontInfo, QFontMetrics,
+ QFontMetricsF, QGradient, QHelpEvent,
+ QHideEvent, QHoverEvent, QIcon, QIconDragEvent,
+ QIconEngine, QImage, QImageIOHandler, QImageReader,
+ QImageWriter, QInputEvent, QInputMethodEvent,
+ QKeyEvent, QKeySequence, QLinearGradient,
+ QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2,
+ QMatrix3x3, QMatrix3x4, QMatrix4x2, QMatrix4x3,
+ QMatrix4x4, QMouseEvent, QMoveEvent, QMovie,
+ QPaintDevice, QPaintEngine, QPaintEngineState,
+ QPaintEvent, QPainter, QPainterPath,
+ QPainterPathStroker, QPalette, QPen, QPicture,
+ QPictureIO, QPixmap, QPixmapCache, QPolygon,
+ QPolygonF, QQuaternion, QRadialGradient,
+ QRegExpValidator, QRegion, QResizeEvent,
+ QSessionManager, QShortcutEvent, QShowEvent,
+ QStandardItem, QStandardItemModel,
+ QStatusTipEvent, QSyntaxHighlighter, QTabletEvent,
+ QTextBlock, QTextBlockFormat, QTextBlockGroup,
+ QTextBlockUserData, QTextCharFormat, QTextCursor,
+ QTextDocument, QTextDocumentFragment,
+ QTextFormat, QTextFragment,
+ QTextFrame, QTextFrameFormat, QTextImageFormat,
+ QTextInlineObject, QTextItem, QTextLayout,
+ QTextLength, QTextLine, QTextList, QTextListFormat,
+ QTextObject, QTextObjectInterface, QTextOption,
+ QTextTable, QTextTableCell, QTextTableCellFormat,
+ QTextTableFormat, QTouchEvent, QTransform,
+ QValidator, QVector2D, QVector3D, QVector4D,
+ QWhatsThisClickedEvent, QWheelEvent,
+ QWindowStateChangeEvent, qAlpha, qBlue,
+ qGray, qGreen, qIsGray, qRed, qRgb, qRgba)
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/QtNetwork.py b/qtpy/QtNetwork.py
new file mode 100644
index 0000000..d905638
--- /dev/null
+++ b/qtpy/QtNetwork.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014-2015 Colin Duquesnoy
+# Copyright © 2009- The Spyder Development Team
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides QtNetwork classes and functions.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PYSIDE_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtNetwork import *
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.QtNetwork import *
+elif os.environ[QT_API] in PYSIDE_API:
+ from PySide.QtNetwork import *
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/QtPrintSupport.py b/qtpy/QtPrintSupport.py
new file mode 100644
index 0000000..d728b61
--- /dev/null
+++ b/qtpy/QtPrintSupport.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2009- The Spyder Development Team
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides QtPrintSupport classes and functions.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PYSIDE_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtPrintSupport import *
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.QtGui import (QAbstractPrintDialog, QPageSetupDialog,
+ QPrintDialog, QPrintEngine, QPrintPreviewDialog,
+ QPrintPreviewWidget, QPrinter, QPrinterInfo)
+elif os.environ[QT_API] in PYSIDE_API:
+ from PySide.QtGui import (QAbstractPrintDialog, QPageSetupDialog,
+ QPrintDialog, QPrintEngine, QPrintPreviewDialog,
+ QPrintPreviewWidget, QPrinter, QPrinterInfo)
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/QtSvg.py b/qtpy/QtSvg.py
new file mode 100644
index 0000000..4aca018
--- /dev/null
+++ b/qtpy/QtSvg.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2009- The Spyder Development Team
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides QtSvg classes and functions.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PYSIDE_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtSvg import *
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.QtSvg import *
+elif os.environ[QT_API] in PYSIDE_API:
+ from PySide.QtSvg import *
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/QtTest.py b/qtpy/QtTest.py
new file mode 100644
index 0000000..0f91160
--- /dev/null
+++ b/qtpy/QtTest.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014-2015 Colin Duquesnoy
+# Copyright © 2009- The Spyder Developmet Team
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides QtTest and functions
+.. warning:: PySide is not supported here, that's why there is not unit tests
+ running with PySide.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PYSIDE_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtTest import QTest
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.QtTest import QTest as OldQTest
+
+ class QTest(OldQTest):
+ @staticmethod
+ def qWaitForWindowActive(QWidget):
+ OldQTest.qWaitForWindowShown(QWidget)
+elif os.environ[QT_API] in PYSIDE_API:
+ raise ImportError('QtTest support is incomplete for PySide')
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/QtWebKit.py b/qtpy/QtWebKit.py
new file mode 100644
index 0000000..c2c0363
--- /dev/null
+++ b/qtpy/QtWebKit.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014-2015 Colin Duquesnoy
+# Copyright © 2009- The Spyder development Team
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides QtWebkit classes and functions.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PYSIDE_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtWebKitWidgets import QWebPage, QWebView
+ from PyQt5.QtWebKit import QWebSettings
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.QtWebKit import QWebPage, QWebView, QWebSettings
+elif os.environ[QT_API] in PYSIDE_API:
+ from PySide.QtWebKit import *
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/QtWidgets.py b/qtpy/QtWidgets.py
new file mode 100644
index 0000000..9a9de3a
--- /dev/null
+++ b/qtpy/QtWidgets.py
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2014-2015 Colin Duquesnoy
+# Copyright © 2009- The Spyder Developmet Team
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+Provides widget classes and functions.
+.. warning:: Only PyQt4/PySide QtGui classes compatible with PyQt5.QtWidgets
+ are exposed here. Therefore, you need to treat/use this package as if it
+ were the ``PyQt5.QtWidgets`` module.
+"""
+
+import os
+
+from qtpy import QT_API
+from qtpy import PYQT5_API
+from qtpy import PYQT4_API
+from qtpy import PYSIDE_API
+from qtpy import PythonQtError
+
+
+if os.environ[QT_API] in PYQT5_API:
+ from PyQt5.QtWidgets import *
+elif os.environ[QT_API] in PYQT4_API:
+ from PyQt4.QtGui import *
+ QStyleOptionViewItem = QStyleOptionViewItemV4
+
+ del (QAbstractTextDocumentLayout, QActionEvent, QBitmap, QBrush, QClipboard,
+ QCloseEvent, QColor, QConicalGradient, QContextMenuEvent, QCursor,
+ QDesktopServices, QDoubleValidator, QDrag, QDragEnterEvent,
+ QDragLeaveEvent, QDragMoveEvent, QDropEvent, QFileOpenEvent,
+ QFocusEvent, QFont, QFontDatabase, QFontInfo, QFontMetrics,
+ QFontMetricsF, QGlyphRun, QGradient, QHelpEvent, QHideEvent,
+ QHoverEvent, QIcon, QIconDragEvent, QIconEngine, QImage,
+ QImageIOHandler, QImageReader, QImageWriter, QInputEvent,
+ QInputMethodEvent, QKeyEvent, QKeySequence, QLinearGradient,
+ QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2, QMatrix3x3,
+ QMatrix3x4, QMatrix4x2, QMatrix4x3, QMatrix4x4, QMouseEvent,
+ QMoveEvent, QMovie, QPaintDevice, QPaintEngine, QPaintEngineState,
+ QPaintEvent, QPainter, QPainterPath, QPainterPathStroker, QPalette,
+ QPen, QPicture, QPictureIO, QPixmap, QPixmapCache, QPolygon,
+ QPolygonF, QQuaternion, QRadialGradient, QRawFont, QRegExpValidator,
+ QRegion, QResizeEvent, QSessionManager, QShortcutEvent, QShowEvent,
+ QStandardItem, QStandardItemModel, QStaticText, QStatusTipEvent,
+ QSyntaxHighlighter, QTabletEvent, QTextBlock, QTextBlockFormat,
+ QTextBlockGroup, QTextBlockUserData, QTextCharFormat, QTextCursor,
+ QTextDocument, QTextDocumentFragment, QTextDocumentWriter,
+ QTextFormat, QTextFragment, QTextFrame, QTextFrameFormat,
+ QTextImageFormat, QTextInlineObject, QTextItem, QTextLayout,
+ QTextLength, QTextLine, QTextList, QTextListFormat, QTextObject,
+ QTextObjectInterface, QTextOption, QTextTable, QTextTableCell,
+ QTextTableCellFormat, QTextTableFormat, QTouchEvent, QTransform,
+ QValidator, QVector2D, QVector3D, QVector4D, QWhatsThisClickedEvent,
+ QWheelEvent, QWindowStateChangeEvent, qAlpha, qBlue, qFuzzyCompare,
+ qGray, qGreen, qIsGray, qRed, qRgb, qRgba)
+
+ del (QAbstractPrintDialog, QPageSetupDialog, QPrintDialog, QPrintEngine,
+ QPrintPreviewDialog, QPrintPreviewWidget, QPrinter, QPrinterInfo)
+elif os.environ[QT_API] in PYSIDE_API:
+ from PySide.QtGui import *
+ QStyleOptionViewItem = QStyleOptionViewItemV4
+
+ del (QAbstractTextDocumentLayout, QActionEvent, QBitmap, QBrush, QClipboard,
+ QCloseEvent, QColor, QConicalGradient, QContextMenuEvent, QCursor,
+ QDesktopServices, QDoubleValidator, QDrag, QDragEnterEvent,
+ QDragLeaveEvent, QDragMoveEvent, QDropEvent, QFileOpenEvent,
+ QFocusEvent, QFont, QFontDatabase, QFontInfo, QFontMetrics,
+ QFontMetricsF, QGradient, QHelpEvent, QHideEvent,
+ QHoverEvent, QIcon, QIconDragEvent, QIconEngine, QImage,
+ QImageIOHandler, QImageReader, QImageWriter, QInputEvent,
+ QInputMethodEvent, QKeyEvent, QKeySequence, QLinearGradient,
+ QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2, QMatrix3x3,
+ QMatrix3x4, QMatrix4x2, QMatrix4x3, QMatrix4x4, QMouseEvent,
+ QMoveEvent, QMovie, QPaintDevice, QPaintEngine, QPaintEngineState,
+ QPaintEvent, QPainter, QPainterPath, QPainterPathStroker, QPalette,
+ QPen, QPicture, QPictureIO, QPixmap, QPixmapCache, QPolygon,
+ QPolygonF, QQuaternion, QRadialGradient, QRegExpValidator,
+ QRegion, QResizeEvent, QSessionManager, QShortcutEvent, QShowEvent,
+ QStandardItem, QStandardItemModel, QStatusTipEvent,
+ QSyntaxHighlighter, QTabletEvent, QTextBlock, QTextBlockFormat,
+ QTextBlockGroup, QTextBlockUserData, QTextCharFormat, QTextCursor,
+ QTextDocument, QTextDocumentFragment,
+ QTextFormat, QTextFragment, QTextFrame, QTextFrameFormat,
+ QTextImageFormat, QTextInlineObject, QTextItem, QTextLayout,
+ QTextLength, QTextLine, QTextList, QTextListFormat, QTextObject,
+ QTextObjectInterface, QTextOption, QTextTable, QTextTableCell,
+ QTextTableCellFormat, QTextTableFormat, QTouchEvent, QTransform,
+ QValidator, QVector2D, QVector3D, QVector4D, QWhatsThisClickedEvent,
+ QWheelEvent, QWindowStateChangeEvent, qAlpha, qBlue, qGray, qGreen,
+ qIsGray, qRed, qRgb, qRgba)
+
+ del (QAbstractPrintDialog, QPageSetupDialog, QPrintDialog, QPrintEngine,
+ QPrintPreviewDialog, QPrintPreviewWidget, QPrinter, QPrinterInfo)
+else:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/__init__.py b/qtpy/__init__.py
new file mode 100644
index 0000000..e9ad184
--- /dev/null
+++ b/qtpy/__init__.py
@@ -0,0 +1,129 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2009- The Spyder Development Team
+# Copyright © 2014-2015 Colin Duquesnoy
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+"""
+**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).
+
+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
+=====
+
+For PyQt5, you don't have to set anything as it will be used automatically::
+
+ >>> from qtpy import QtGui, QtWidgets, QtCore
+ >>> print(QtWidgets.QWidget)
+
+
+PyQt4
+=====
+
+Set the ``QT_API`` environment variable to 'pyqt' before importing any python
+package::
+
+ >>> import os
+ >>> os.environ['QT_API'] = 'pyqt'
+ >>> from qtpy import QtGui, QtWidgets, QtCore
+ >>> print(QtWidgets.QWidget)
+
+PySide
+======
+
+Set the QT_API environment variable to 'pyside' before importing other
+packages::
+
+ >>> import os
+ >>> os.environ['QT_API'] = 'pyside'
+ >>> from qtpy import QtGui, QtWidgets, QtCore
+ >>> print(QtWidgets.QWidget)
+
+"""
+
+import os
+
+#: Qt API environment variable name
+QT_API = 'QT_API'
+#: names of the expected PyQt5 api
+PYQT5_API = ['pyqt5']
+#: names of the expected PyQt4 api
+PYQT4_API = [
+ 'pyqt', # name used in IPython.qt
+ 'pyqt4' # pyqode.qt original name
+]
+#: names of the expected PySide api
+PYSIDE_API = ['pyside']
+
+os.environ.setdefault(QT_API, 'pyqt5')
+assert os.environ[QT_API] in (PYQT5_API + PYQT4_API + PYSIDE_API)
+
+API = os.environ[QT_API]
+API_NAME = {'pyqt5': 'PyQt5', 'pyqt': 'PyQt4', 'pyqt4': 'PyQt4',
+ 'pyside': 'PySide'}[API]
+
+is_old_pyqt = is_pyqt46 = False
+PYQT5 = True
+PYQT4 = PYSIDE = False
+
+
+class PythonQtError(Exception):
+ """Error raise if no bindings could be selected"""
+ pass
+
+
+if API in PYQT5_API:
+ try:
+ from PyQt5.QtCore import PYQT_VERSION_STR as __version__
+ from PyQt5 import uic # analysis:ignore
+ except ImportError:
+ API = os.environ['QT_API'] = 'pyqt'
+ API_NAME = 'PyQt4'
+
+if API in PYQT4_API:
+ try:
+ import sip
+ try:
+ sip.setapi('QString', 2)
+ sip.setapi('QVariant', 2)
+ sip.setapi('QDate', 2)
+ sip.setapi('QDateTime', 2)
+ sip.setapi('QTextStream', 2)
+ sip.setapi('QTime', 2)
+ sip.setapi('QUrl', 2)
+ except AttributeError:
+ # PyQt < v4.6
+ pass
+
+ from PyQt4.QtCore import PYQT_VERSION_STR as __version__ # analysis:ignore
+ from PyQt4 import uic # analysis:ignore
+ PYQT5 = False
+ PYQT4 = True
+ except ImportError:
+ API = os.environ['QT_API'] = 'pyside'
+ API_NAME = 'PySide'
+ else:
+ is_old_pyqt = __version__.startswith(('4.4', '4.5', '4.6', '4.7'))
+ is_pyqt46 = __version__.startswith('4.6')
+ import sip
+ try:
+ API_NAME += (" (API v%d)" % sip.getapi('QString'))
+ except AttributeError:
+ pass
+
+if API in PYSIDE_API:
+ try:
+ from PySide import __version__ # analysis:ignore
+ PYQT5 = False
+ PYSIDE = True
+ except ImportError:
+ raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/_version.py b/qtpy/_version.py
new file mode 100644
index 0000000..4f208eb
--- /dev/null
+++ b/qtpy/_version.py
@@ -0,0 +1,2 @@
+version_info = (1, 0, 'b1')
+__version__ = '.'.join(map(str, version_info))
diff --git a/qtpy/compat.py b/qtpy/compat.py
new file mode 100644
index 0000000..e15beef
--- /dev/null
+++ b/qtpy/compat.py
@@ -0,0 +1,196 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2009- The Spyder Development Team
+# Licensed under the terms of the MIT License
+
+"""
+Compatibility functions
+"""
+
+from __future__ import print_function
+import os
+import sys
+import collections
+
+from qtpy.QtWidgets import QFileDialog
+from qtpy.py3compat import is_text_string, to_text_string, TEXT_TYPES
+
+
+# =============================================================================
+# QVariant conversion utilities
+# =============================================================================
+PYQT_API_1 = False
+if os.environ['QT_API'] == 'pyqt':
+ import sip
+ try:
+ PYQT_API_1 = sip.getapi('QVariant') == 1 # PyQt API #1
+ except AttributeError:
+ # PyQt <v4.6
+ PYQT_API_1 = True
+
+ def to_qvariant(pyobj=None):
+ """Convert Python object to QVariant
+ This is a transitional function from PyQt API #1 (QVariant exist)
+ to PyQt API #2 and Pyside (QVariant does not exist)"""
+ if PYQT_API_1:
+ # PyQt API #1
+ from PyQt4.QtCore import QVariant
+ return QVariant(pyobj)
... 554 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-qtpy.git
More information about the Python-modules-commits
mailing list