Skip to content

Releases: mottosso/Qt.py

1.2.0.b3

04 Jan 08:31
1f7e1ca
Compare
Choose a tag to compare
1.2.0.b3 Pre-release
Pre-release

Workaround to pyside-77 bug.

See #306 for details. Thanks to @aoblet for this fix!

1.2.0.b2

24 Apr 00:28
2c4a0e0
Compare
Choose a tag to compare
1.2.0.b2 Pre-release
Pre-release

Internal changes to facilitate the QtPyConvert project, should not affect the end-user.

1.1.0

25 Jan 10:48
8a3be69
Compare
Choose a tag to compare

Improved detection of common members

The ability to automatically generate the common members, used by Qt.py, makes it much easier to spot new additions to e.g. PySide2. Run build_membership.sh to generate a JSON file per binding, which are then compared. The result is written to a common_members.json and can be copy-pasted into Qt.py. This comparison leverages the tests suite and uses the binding versions used in the latest test suite.

Once the binding versions used by the tests suite gets updated (usually annually during a VFX Platform update), we will check for new members, using this new approach.

See DOCKER.md for more info.


New members

QtCore.QItemSelectionRange  # thanks to @Ahuge 
QtCore.QT_TRANSLATE_NOOP
QtCore.QT_TR_NOOP
QtCore.QT_TR_NOOP_UTF8

QtGui.DesktopServices
QtGui.QTouchEvent
QtGui.qRgba

QtMultimedia.QAbstractVideoBuffer
QtMultimedia.QAbstractVideoSurface
QtMultimedia.QAudio
QtMultimedia.QAudioDeviceInfo
QtMultimedia.QAudioFormat
QtMultimedia.QAudioInput
QtMultimedia.QAudioOutput
QtMultimedia.QVideoFrame
QtMultimedia.QVideoSurfaceFormat

QtPrintSupport.QAbstractPrintDialog
QtPrintSupport.QPageSetupDialog
QtPrintSupport.QPrintDialog
QtPrintSupport.QPrintEngine
QtPrintSupport.QPrintPreviewDialog
QtPrintSupport.QPrintPreviewWidget
QtPrintSupport.QPrinter
QtPrintSupport.QPrinterInfo

QtSql.QSql
QtSql.QSqlDatabase
QtSql.QSqlDriver
QtSql.QSqlDriverCreatorBase
QtSql.QSqlError
QtSql.QSqlField
QtSql.QSqlIndex
QtSql.QSqlQuery
QtSql.QSqlQueryModel
QtSql.QSqlRecord
QtSql.QSqlRelation
QtSql.QSqlRelationalDelegate
QtSql.QSqlRelationalTableModel
QtSql.QSqlResult
QtSql.QSqlTableModelQtSql

QtSvg.QGraphicsSvgItem
QtSvg.QSvgGenerator
QtSvg.QSvgRenderer
QtSvg.QSvgWidget

QTest.QTest

QtX11Extras.QX11Info  # thanks to @assumptionsoup

QtXmlPatterns.QAbstractMessageHandler
QtXmlPatterns.QAbstractUriResolver
QtXmlPatterns.QAbstractXmlNodeModel
QtXmlPatterns.QAbstractXmlReceiver
QtXmlPatterns.QSourceLocation
QtXmlPatterns.QXmlFormatter
QtXmlPatterns.QXmlItem
QtXmlPatterns.QXmlName
QtXmlPatterns.QXmlNamePool
QtXmlPatterns.QXmlNodeModelIndex
QtXmlPatterns.QXmlQuery
QtXmlPatterns.QXmlResultItems
QtXmlPatterns.QXmlSchema
QtXmlPatterns.QXmlSchemaValidator
QtXmlPatterns.QXmlSerializer"

Removed QtCore.QMetaType member

The QtCore.QMetaType member was removed as it was wrongly added to Qt.py.


New tests suite

A new tests suite was added. Qt and its bindings are compiled from source using the CY2018 VFX Platform standards. This adds better support for testing with Python 3.x and removes the dependency of the Ubuntu PPAs previously used to install the Qt bindings.

cd Qt.py

# Run nosetests (Linux/OSX)
docker run --rm -v $(pwd):/Qt.py -e PYTHON=2.7 fredrikaverpil/qt.py:2018
docker run --rm -v $(pwd):/Qt.py -e PYTHON=3.4 fredrikaverpil/qt.py:2018
docker run --rm -v $(pwd):/Qt.py -e PYTHON=3.5 fredrikaverpil/qt.py:2018
docker run --rm -v $(pwd):/Qt.py -e PYTHON=3.6 fredrikaverpil/qt.py:2018

# Run nosetests (Windows)
docker run --rm -v %CD%:/Qt.py -e PYTHON=2.7 fredrikaverpil/qt.py:2018
docker run --rm -v %CD%:/Qt.py -e PYTHON=3.4 fredrikaverpil/qt.py:2018
docker run --rm -v %CD%:/Qt.py -e PYTHON=3.5 fredrikaverpil/qt.py:2018
docker run --rm -v %CD%:/Qt.py -e PYTHON=3.6 fredrikaverpil/qt.py:2018

The test suite will be updated anually, around the time of SIGGRAPH and when the VFX Platform usually gets updated.

For more information on running the tests, see README.md and DOCKER.md.


Support for Python 2.6

Qt.py now works with Python 2.6, thanks to contributions made by @Ahuge (see #245). However, keep in mind that the automatic tests don't apply to Python 2.6.


Upgraded QtCompat

An additional layer was added to QtCompat to facilitate more members.

Before

from Qt import QtCompat
QtCompat.setSectionResizeMode

After

from Qt import QtCompat
QtCompat.QHeaderView.setSectionResizeMode

Backwards compatibility is maintained, at least till the next major version release.


Pre-release installation

Install

To install a pre-release, prepend --pre to your pip install.

$ pip install --pre -U Qt.py

To upgrade an existing install, prepend -U as well.

$ pip install --pre Qt.py

QtSiteConfig

Version 1.1.0.b3 added support for overriding available members of Qt.py on import, to either add custom members and modules, or remove them.


Added wrapInstance and getCppPointer

The shiboken of PySide and sip of PyQt have found a home in QtCompat.

from Qt import QtCompat
QtCompat.wrapInstance(...)

They work similar as you would expect. See the release notes for 1.1.0.b1 for details and examples.

1.1.0.b10

15 Jan 11:47
71991d3
Compare
Choose a tag to compare
1.1.0.b10 Pre-release
Pre-release

Adds support for from Qt.QtCompat import X.

See #265 for details.

1.1.0.b9

20 Dec 06:21
952b91d
Compare
Choose a tag to compare
1.1.0.b9 Pre-release
Pre-release

Improvements to QtCompat.loadUi().

  • See #217 for details.

1.1.0.b8

15 Dec 09:21
cb4f3e7
Compare
Choose a tag to compare
1.1.0.b8 Pre-release
Pre-release

Here are the changes coming from #234:

A new tests suite was added. Qt and its bindings are compiled from source using the CY2018 VFX Platform standards. This adds better support for testing with Python 3.x and removes the dependency of the Ubuntu PPAs previously used to install the Qt bindings.

  • The common members dictionary is now based on a proper comparison. As a result, new members were found to be common. Run build_membership.py to generate JSON files which gets compared and in finally generates common_bindings.json which serves as a base for the common_members dictionary in Qt.py.
  • DOCKER.md README.md were updated with instructions and details on testing.
  • QtCompat.wrapInstance caveats test is skipped with PySide2 due to this having been addressed by QtC.

1.1.0.b7

23 Nov 07:51
11bf305
Compare
Choose a tag to compare
1.1.0.b7 Pre-release
Pre-release

Added support (where available) for QtX11Extras.

Thanks to @assumptionsoup for this feature!

1.1.0.b6

10 Nov 21:47
ebf8493
Compare
Choose a tag to compare
1.1.0.b6 Pre-release
Pre-release

Re-added QItemSelectionRange to QtCore.

Thanks @Ahuge!

1.1.0.b4

21 Sep 05:18
Compare
Choose a tag to compare
1.1.0.b4 Pre-release
Pre-release

Support for Python 2.6.

Thanks @Ahuge!

1.1.0.b3

10 Aug 10:05
Compare
Choose a tag to compare
1.1.0.b3 Pre-release
Pre-release

Upgraded QtCompat

An additional layer was added to QtCompat to facilitate more members.

Before

from Qt import QtCompat
QtCompat.setSectionResizeMode

After

from Qt import QtCompat
QtCompat.QHeaderView.setSectionResizeMode

Backwards compatibility is maintained till the next major version release.


QtSiteConfig example

From /examples

This example illustrates how to make a QtSiteConfig module and how it affects Qt.py at run-time.

Usage

$ cd to/this/directory
$ python main.py
# Qt.QtCore was successfully removed by QSiteConfig.py

Because QtSiteConfig.py is in the current working directory, it is available to import by Python. If running from a different directory, then you can append this directory to your PYTHONPATH

$ set PYTHONPATH=path/to/QtSiteConfig/
$ python main.py
# Qt.QtCore was successfully removed by QSiteConfig.py

Linux and MacOS users: Replace set with export


Advanced examples

If you need to you can also add modules that are not in the standard Qt.py. All of these functions are optional in QtSiteConfig, so only implement the functions you need.

QtSiteConfig.py: Adding non-standard modules

By default Qt.py only exposes the "lowest common denominator" of all bindings. This example shows how to add the Qsci module that is not included by default with Qt.py.

def update_members(members):
    """An example of adding Qsci to Qt.py.

    Arguments:
        members (dict): The default list of members in Qt.py.
            Update this dict with any modifications needed.
    """

    # Include Qsci module for scintilla lexer support.
    members["Qsci"] = [
        "QsciAPIs",
        "QsciAbstractAPIs",
        "QsciCommand",
        "QsciCommandSet",
        "QsciDocument",
        "QsciLexer",
        "QsciLexerAVS",
        "QsciLexerBash",
        "QsciLexerBatch",
        "QsciLexerCMake",
        "QsciLexerCPP",
        "QsciLexerCSS",
        "QsciLexerCSharp",
        "QsciLexerCoffeeScript",
        "QsciLexerCustom",
        "QsciLexerD",
        "QsciLexerDiff",
        "QsciLexerFortran",
        "QsciLexerFortran77",
        "QsciLexerHTML",
        "QsciLexerIDL",
        "QsciLexerJSON",
        "QsciLexerJava",
        "QsciLexerJavaScript",
        "QsciLexerLua",
        "QsciLexerMakefile",
        "QsciLexerMarkdown",
        "QsciLexerMatlab",
        "QsciLexerOctave",
        "QsciLexerPO",
        "QsciLexerPOV",
        "QsciLexerPascal",
        "QsciLexerPerl",
        "QsciLexerPostScript",
        "QsciLexerProperties",
        "QsciLexerPython",
        "QsciLexerRuby",
        "QsciLexerSQL",
        "QsciLexerSpice",
        "QsciLexerTCL",
        "QsciLexerTeX",
        "QsciLexerVHDL",
        "QsciLexerVerilog",
        "QsciLexerXML",
        "QsciLexerYAML",
        "QsciMacro",
        "QsciPrinter",
        "QsciScintilla",
        "QsciScintillaBase",
        "QsciStyle",
        "QsciStyledText",
    ]

QtSiteConfig.py: Standardizing the location of Qt classes

Some classes have been moved to new locations between bindings. Qt.py uses the namespace dictated by PySide2 and most members are already in place.
This example reproduces functionality already in Qt.py but it provides a good example of how use this function.

def update_misplaced_members(members):
    """This optional function is called by Qt.py to standardize the location
    and naming of exposed classes.

    Arguments:
        members (dict): The members considered by Qt.py
    """
    # Standardize the the Property name
    members["PySide2"]["QtCore.Property"] = "QtCore.Property"
    members["PyQt5"]["QtCore.pyqtProperty"] = "QtCore.Property"
    members["PySide"]["QtCore.Property"] = "QtCore.Property"
    members["PyQt4"]["QtCore.pyqtProperty"] = "QtCore.Property"

QtSiteConfig.py: Standardizing PyQt4's QFileDialog functionality

This example reproduces functionality already in Qt.py but it provides a good example of what is necessary to create your QtCompat namespaces with custom method decorators to change how the source method runs.

def update_compatibility_members(members):
    """This function is called by Qt.py to modify the modules it exposes.

    Arguments:
        members (dict): The members considered by Qt.py
    """
    members['PyQt4']["QFileDialog"] = {
        "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName",
        "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames",
        "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName",
    }

def update_compatibility_decorators(binding, decorators):
    """ This function is called by Qt.py to modify the decorators applied to
    QtCompat namespace objects. Defining this method is optional.

    Arguments:
        binding (str): The Qt binding being wrapped by Qt.py
        decorators (dict): Maps specific decorator methods to
            QtCompat namespace methods. See Qt._build_compatibility_members
            for more info.
    """
    if binding == 'PyQt4':
        # QFileDialog QtCompat decorator
        def _standardizeQFileDialog(some_function):
            """ decorator that makes PyQt4 return conform to other bindings
            """
            def wrapper(*args, **kwargs):
                ret = some_function(*args, **kwargs)
                # PyQt4 only returns the selected filename, force it to a
                # standard return of the selected filename, and a empty string
                # for the selected filter
                return (ret, '')
            # preserve docstring and name of original method
            wrapper.__doc__ = some_function.__doc__
            wrapper.__name__ = some_function.__name__
            return wrapper

        decorators.setdefault("QFileDialog",{})["getOpenFileName"] = \
            _standardizeQFileDialog
        decorators.setdefault("QFileDialog",{})["getOpenFileNames"] = \
            _standardizeQFileDialog
        decorators.setdefault("QFileDialog",{})["getSaveFileName"] = \
            _standardizeQFileDialog