uncrumpled_async_gui


Nameuncrumpled_async_gui JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/reclosedev/async_gui
SummaryEasy threading and multiprocessing for GUI applications
upload_time2017-04-02 13:13:30
maintainer
docs_urlNone
authorRoman Haritonov
requires_python
licenseBSD License
keywords gui
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            async_gui
---------------

``async_gui`` is a library aimed to make use of threads in GUI applications simpler.
It's inspired by PyCon talk
`Using futures for async GUI programming in Python 3.3 <http://pyvideo.org/video/1762/using-futures-for-async-gui-programming-in-python>`_
and `tornado <https://github.com/facebook/tornado>`_ ``@gen.engine`` implementation.

Most of GUI toolkits don't allow you to access graphical elements from non-GUI thread.
Python 3.2+ has nice new feature ``concurrent.futures``, but we can't just
wait for result from future and callbacks are not very handy.

Combination of `Coroutines via Enhanced Generators (PEP-342) <http://www.python.org/dev/peps/pep-0342/>`_
and ``futures`` creates a rich and easy to use asynchronous programming model
which can be used for creating highly responsive GUI applications.


Example
-------

Demo of button click handler:

.. code-block:: python

    @engine.async
    def on_button_click(self, *args):
        self.status_label.setText("Downloading image...")
        # Run single task in separate thread
        image_data = yield Task(self.load_url,
                                "http://www.google.com/images/srpr/logo4w.png")
        pixmap = QtGui.QPixmap.fromImage(QtGui.QImage.fromData(image_data))
        self.image_label.setPixmap(pixmap)
        self.status_label.setText("Downloading pages...")
        urls = ['http://www.google.com',
                'http://www.yandex.ru',
                'http://www.python.org']
        # Run multiple task simultaneously in thread pool
        pages = yield [Task(self.load_url, url) for url in urls]
        self.status_label.setText("Done")
        avg_size = sum(map(len, pages)) / len(pages)
        self.result_label.setText("Average page size: %s" % avg_size)


Tasks yielded from ``on_button_click()`` executed in thread pool, but
GUI updates done in the GUI thread.
For CPU-bound applications there is also ability to run tasks in pool of
processes.

See `full example <https://github.com/reclosedev/async_gui/blob/master/examples/qt_app.py>`_
in `examples <https://github.com/reclosedev/async_gui/tree/master/examples>`_ directory.


Features
--------

- Python 2.7+ (`futures <https://pypi.python.org/pypi/futures>`_ required),
  Python 3+ support

- PyQt4/PySide, Tk, Wx, Gtk GUI toolkits support. Easy to add another

- Can execute tasks in Thread, Process, Greenlet (`gevent <http://www.gevent.org/>`_ required)

- Possibility to run multiple tasks at the same time

- Straightforward exception handling

- Full test coverage

Installation
------------

Using pip_::

    $ pip install async_gui

Or download, unpack and::

    $ python setup.py install


To run tests use::

    $ python setup.py test

.. _pip: http://www.pip-installer.org/en/latest/installing.html

Links
-----

- **Documentation** at `readthedocs.org <https://async_gui.readthedocs.org/en/latest/>`_

- **Source code and issue tracking** at `GitHub <https://github.com/reclosedev/async_gui>`_.



.. :changelog:

History
-------

0.2.0 (2013-0x-xx)
+++++++++++++++++++

* MultiTask can return generator of ready tasks instead waiting for all done


0.1.0 (2013-04-06)
+++++++++++++++++++

* initial PyPI release
            

Raw data

            {
    "_id": null,
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "cheesecake_code_kwalitee_id": null,
    "keywords": "GUI",
    "upload_time": "2017-04-02 13:13:30",
    "author": "Roman Haritonov",
    "home_page": "https://github.com/reclosedev/async_gui",
    "github_user": "reclosedev",
    "download_url": "https://pypi.python.org/packages/63/a0/5eca0afcb653c40af3eb5779a3ca47c125ad5c7763dfd296663f7d21001d/uncrumpled_async_gui-0.1.1.tar.gz",
    "platform": "",
    "version": "0.1.1",
    "cheesecake_documentation_id": null,
    "description": "async_gui\n---------------\n\n``async_gui`` is a library aimed to make use of threads in GUI applications simpler.\nIt's inspired by PyCon talk\n`Using futures for async GUI programming in Python 3.3 <http://pyvideo.org/video/1762/using-futures-for-async-gui-programming-in-python>`_\nand `tornado <https://github.com/facebook/tornado>`_ ``@gen.engine`` implementation.\n\nMost of GUI toolkits don't allow you to access graphical elements from non-GUI thread.\nPython 3.2+ has nice new feature ``concurrent.futures``, but we can't just\nwait for result from future and callbacks are not very handy.\n\nCombination of `Coroutines via Enhanced Generators (PEP-342) <http://www.python.org/dev/peps/pep-0342/>`_\nand ``futures`` creates a rich and easy to use asynchronous programming model\nwhich can be used for creating highly responsive GUI applications.\n\n\nExample\n-------\n\nDemo of button click handler:\n\n.. code-block:: python\n\n    @engine.async\n    def on_button_click(self, *args):\n        self.status_label.setText(\"Downloading image...\")\n        # Run single task in separate thread\n        image_data = yield Task(self.load_url,\n                                \"http://www.google.com/images/srpr/logo4w.png\")\n        pixmap = QtGui.QPixmap.fromImage(QtGui.QImage.fromData(image_data))\n        self.image_label.setPixmap(pixmap)\n        self.status_label.setText(\"Downloading pages...\")\n        urls = ['http://www.google.com',\n                'http://www.yandex.ru',\n                'http://www.python.org']\n        # Run multiple task simultaneously in thread pool\n        pages = yield [Task(self.load_url, url) for url in urls]\n        self.status_label.setText(\"Done\")\n        avg_size = sum(map(len, pages)) / len(pages)\n        self.result_label.setText(\"Average page size: %s\" % avg_size)\n\n\nTasks yielded from ``on_button_click()`` executed in thread pool, but\nGUI updates done in the GUI thread.\nFor CPU-bound applications there is also ability to run tasks in pool of\nprocesses.\n\nSee `full example <https://github.com/reclosedev/async_gui/blob/master/examples/qt_app.py>`_\nin `examples <https://github.com/reclosedev/async_gui/tree/master/examples>`_ directory.\n\n\nFeatures\n--------\n\n- Python 2.7+ (`futures <https://pypi.python.org/pypi/futures>`_ required),\n  Python 3+ support\n\n- PyQt4/PySide, Tk, Wx, Gtk GUI toolkits support. Easy to add another\n\n- Can execute tasks in Thread, Process, Greenlet (`gevent <http://www.gevent.org/>`_ required)\n\n- Possibility to run multiple tasks at the same time\n\n- Straightforward exception handling\n\n- Full test coverage\n\nInstallation\n------------\n\nUsing pip_::\n\n    $ pip install async_gui\n\nOr download, unpack and::\n\n    $ python setup.py install\n\n\nTo run tests use::\n\n    $ python setup.py test\n\n.. _pip: http://www.pip-installer.org/en/latest/installing.html\n\nLinks\n-----\n\n- **Documentation** at `readthedocs.org <https://async_gui.readthedocs.org/en/latest/>`_\n\n- **Source code and issue tracking** at `GitHub <https://github.com/reclosedev/async_gui>`_.\n\n\n\n.. :changelog:\n\nHistory\n-------\n\n0.2.0 (2013-0x-xx)\n+++++++++++++++++++\n\n* MultiTask can return generator of ready tasks instead waiting for all done\n\n\n0.1.0 (2013-04-06)\n+++++++++++++++++++\n\n* initial PyPI release",
    "lcname": "uncrumpled_async_gui",
    "name": "uncrumpled_async_gui",
    "github": true,
    "bugtrack_url": null,
    "license": "BSD License",
    "travis_ci": false,
    "github_project": "async_gui",
    "summary": "Easy threading and multiprocessing for GUI applications",
    "split_keywords": [
        "gui"
    ],
    "author_email": "reclosedev@gmail.com",
    "urls": [
        {
            "has_sig": false,
            "upload_time": "2017-04-02T13:13:32",
            "comment_text": "",
            "python_version": "3.5",
            "url": "https://pypi.python.org/packages/ff/99/9f9783204a6ec7536cb582205fbfaec5e6870b5efa1e74ab36aa81f4418f/uncrumpled_async_gui-0.1.1-py3-none-any.whl",
            "md5_digest": "248d03683da08a0eb949aff6ca880f33",
            "downloads": 0,
            "filename": "uncrumpled_async_gui-0.1.1-py3-none-any.whl",
            "packagetype": "bdist_wheel",
            "path": "ff/99/9f9783204a6ec7536cb582205fbfaec5e6870b5efa1e74ab36aa81f4418f/uncrumpled_async_gui-0.1.1-py3-none-any.whl",
            "size": 12888
        },
        {
            "has_sig": false,
            "upload_time": "2017-04-02T13:13:30",
            "comment_text": "",
            "python_version": "source",
            "url": "https://pypi.python.org/packages/63/a0/5eca0afcb653c40af3eb5779a3ca47c125ad5c7763dfd296663f7d21001d/uncrumpled_async_gui-0.1.1.tar.gz",
            "md5_digest": "75652fd778269871a83d23d0f0c19abd",
            "downloads": 0,
            "filename": "uncrumpled_async_gui-0.1.1.tar.gz",
            "packagetype": "sdist",
            "path": "63/a0/5eca0afcb653c40af3eb5779a3ca47c125ad5c7763dfd296663f7d21001d/uncrumpled_async_gui-0.1.1.tar.gz",
            "size": 21428
        }
    ],
    "cheesecake_installability_id": null,
    "coveralls": true
}
        
Elapsed time: 0.04302s