Skip to main content

A set of distutils extension for building Qt ui files

Project description

Latest PyPI version Number of PyPI downloads

A set of distutils extension to work with PyQt applications and UI files.

The goal of this tiny library is to help you write PyQt application in a pythonic way, using setup.py to build the Qt designer Ui files.

This works with PyQt4, PyQt5 and PySide (tested with python3 only).

Usage

Add the following lines to your setup.py:

# import build_ui
try:
    from pyqt_distutils.build_ui import build_ui
    cmdclass = {'build_ui': build_ui}
except ImportError:
    build_ui = None  # user won't have pyqt_distutils when deploying
    cmdclass = {}

...

setup(...,
      cmdclass=cmdclass)

To build the ui/qrc files, run:

python setup.py build_ui

To forcibly rebuilt every files, use the --force option:

python setup.py build_ui --force

UI Files

The compilation of ui files is driven by a pyuic.json file, which is a plain json file with the following format:

{
    "files": [
        [
            "forms/main_window.ui",
            "package/forms"
        ]
    ],
    "pyrcc": "pyrcc5",
    "pyrcc_options": "",
    "pyuic": "pyuic5",
    "pyuic_options": "--from-imports"
}

Here is a brief description of the fields:

  • files: list of file pairs made up of the source ui file and the destination package

  • pyrcc: the name of the pyrcc tool to use (e.g: ‘pyrcc4’ or ‘pyside-rcc’)

  • pyrcc_options: pyrcc options (optional)

  • pyuic: the name of the pyuic tool to use (e.g: ‘pyrcc4’ or ‘pyside-rcc’)

Starting from version 3.0, you can use a glob expression instead of a file path. E.g., to compile all ui files under the forms directory in package/forms, you could write the following pyuic.json:

{
    "files": [
        [
            "forms/*.ui",
            "package/forms"
        ]
    ],
    "pyrcc": "pyrcc5",
    "pyrcc_options": "",
    "pyuic": "pyuic5",
    "pyuic_options": "--from-imports"
}

Command line tool

Starting from version 0.2, you can use the pyuicfg command line tool to manage your pyuic.json file:

# generate pyuic.json in the current directory, for use with PyQt4
pyuicfg -g

# generate pyuic.json in the current directory, for use with PyQt5
pyuicfg -g --pyqt5

# generate pyuic.json in the current directory, for use with PySide
pyuicfg -g --pyside

# add files
pyuicfg -a forms/main_window.ui foo_package/forms
pyuicfg -a resources/foo.qrc foo_package/forms

# remove file
pyuicfg -r resources/foo.qrc

Requirements

The following packages are required:

  • docopt

Install

You can either install from pypi:

(sudo) pip install pyqt-distutils

Or from source:

pip install .

License

This project is licensed under the MIT license.

Changelog

0.5.2

  • remove enum34 dependency and make the wheel truly universal

0.5.1

  • fix installation issue on python 3.5

0.5.0

  • allow the use of .json extension instead of .cfg (both are supported, .json become the default extension)

0.4.2

  • fix python 2 compatibility (#2)

0.4.1

  • remove useless and confusing print statement

0.4.0

  • add a --force flag

  • always force compilation *.qrc files

0.3.0

  • allow glob expression in files lists.

0.2.1

  • fix missing install requirements (docopt and enum34).

0.2.0

  • add pyuicfg command line tool to administrate your pyuic.cfg file.

0.1.2

  • Improve readme

0.1.1

  • Fix description and examples when pyqt-distutils has not been installed.

0.1.0

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt-distutils-0.5.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

pyqt_distutils-0.5.2-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyqt-distutils-0.5.2.tar.gz.

File metadata

File hashes

Hashes for pyqt-distutils-0.5.2.tar.gz
Algorithm Hash digest
SHA256 d0c0b72068d636c8d83e3fec6f5c5ec3959ab6c654eb297ac525136e262eb92b
MD5 d9f68d061ba5108851ef2a528a5f6cab
BLAKE2b-256 a0208a321ffb4e43ddf44a80f52e029886a5ee922244a95aa849d5309aa9aa53

See more details on using hashes here.

File details

Details for the file pyqt_distutils-0.5.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyqt_distutils-0.5.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6940f107fad2894a81f29e988777206c84a6a343237f6a03d720f72b2bfd462a
MD5 21df153663abac49ea558dcd32c2417b
BLAKE2b-256 d9465f75e2e4aac2524e5b113529e08767971de3ac9999c0408375908a1dcff4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page