{ "info": { "author": "Justin Engel", "author_email": "jtengel08@gmail.com", "bugtrack_url": null, "classifiers": [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3" ], "description": "# qt_multiprocessing\n\nLong running process that runs along side of the Qt event loop and allows other widgets to live in the other process.\n\n## Quick Start\n\n```python\nimport os\nimport qt_multiprocessing\n\nfrom qtpy import QtWidgets\n\n\nclass MyPIDLabel(QtWidgets.QLabel):\n def print_pid(self):\n text = self.text()\n print(text, 'PID:', os.getpid())\n return text\n\n\nclass MyPIDLabelProxy(qt_multiprocessing.WidgetProxy):\n PROXY_CLASS = MyPIDLabel\n GETTERS = ['text']\n\n\nif __name__ == '__main__':\n with qt_multiprocessing.MpApplication() as app:\n print(\"Main PID:\", os.getpid())\n\n # Proxy\n lbl = MyPIDLabelProxy(\"Hello\")\n\n widg = QtWidgets.QDialog()\n lay = QtWidgets.QFormLayout()\n widg.setLayout(lay)\n\n # Form\n inp = QtWidgets.QLineEdit()\n btn = QtWidgets.QPushButton('Set Text')\n lay.addRow(inp, btn)\n\n def set_text():\n text = inp.text()\n lbl.setText(inp.text())\n\n # Try to somewhat prove that the label is in a different process.\n # `print_pid` Not exposed (will call in other process. Result will be None)\n print('Set Label text', text + '. Label text in this process', lbl.print_pid())\n\n # `print_pid` will run in a separate process and print the pid.\n\n btn.clicked.connect(set_text)\n\n widg.show()\n```\n\nBelow is an example for if you want to manually create widgets in a different process without the proxy.\n\n```python\nimport os\nimport qt_multiprocessing\n\nfrom qtpy import QtWidgets\n\n\nclass MyPIDLabel(QtWidgets.QLabel):\n def print_pid(self):\n text = self.text()\n print(text, 'PID:', os.getpid())\n return text\n\n\ndef create_process_widgets():\n lbl = MyPIDLabel('Hello')\n lbl.show()\n return {'label': lbl}\n\n\nif __name__ == '__main__':\n with qt_multiprocessing.MpApplication(initialize_process=create_process_widgets) as app:\n print(\"Main PID:\", os.getpid())\n\n widg = QtWidgets.QDialog()\n lay = QtWidgets.QFormLayout()\n widg.setLayout(lay)\n\n # Form\n inp = QtWidgets.QLineEdit()\n btn = QtWidgets.QPushButton('Set Text')\n lay.addRow(inp, btn)\n\n def set_text():\n text = inp.text()\n app.add_var_event('label', 'setText', text)\n\n # The label does not exist in this process at all. Can only access by string names\n print('Set Label text', text + '.')\n\n # `print_pid` will run in a separate process and print the pid.\n app.add_var_event('label', 'print_pid')\n\n btn.clicked.connect(set_text)\n\n widg.show()\n```\n\n## How it works\n\nThis library works by creating an event loop in a separate process while the Qt application is running in the main \nprocess. This library is built off of the mp_event_loop library which creates a long running process where events are\nthrown on a queue and executed in a separate process. The other process that is created also runs it's own Qt \napplication while executing events in a timer.\n\nThis library has the ability to:\n * dynamic creation of widgets in a separate process\n * Run methods of widgets in a separate process through variable names\n * Proxy widgets\n \n\n## Manual Example\n\nThis example shows how everything comes together manually\n\n```python\nimport os\nimport qt_multiprocessing\n\nfrom qtpy import QtWidgets\n\n\nclass MyPIDLabel(QtWidgets.QLabel):\n def print_pid(self):\n text = self.text()\n print(text, 'PID:', os.getpid())\n return text\n\n\ndef create_process_widgets():\n lbl = MyPIDLabel('Hello')\n lbl.show()\n return {'label': lbl}\n\n\nif __name__ == '__main__':\n app = QtWidgets.QApplication([])\n mp_loop = qt_multiprocessing.AppEventLoop(initialize_process=create_process_widgets)\n print(\"Main PID:\", os.getpid())\n\n widg = QtWidgets.QDialog()\n lay = QtWidgets.QFormLayout()\n widg.setLayout(lay)\n\n # Form\n inp = QtWidgets.QLineEdit()\n btn = QtWidgets.QPushButton('Set Text')\n lay.addRow(inp, btn)\n\n def set_text():\n text = inp.text()\n mp_loop.add_var_event('label', 'setText', text)\n\n # The label does not exist in this process at all. Can only access by string names\n print('Set Label text', text + '.')\n\n # `print_pid` will run in a separate process and print the pid.\n mp_loop.add_var_event('label', 'print_pid')\n\n btn.clicked.connect(set_text)\n\n widg.show()\n\n # Run the multiprocessing event loop\n mp_loop.start()\n\n # Run the application event loop\n app.exec_()\n\n # Quit the multiprocessing event loop when the app closes\n mp_loop.close()\n```", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/justengel/qt_multiprocessing/archive/v0.0.7.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/justengel/qt_multiprocessing", "keywords": "qt multiprocessing,multiprocessing,event,loop,event loop,process", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "qt-multiprocessing", "package_url": "https://pypi.org/project/qt-multiprocessing/", "platform": "any", "project_url": "https://pypi.org/project/qt-multiprocessing/", "project_urls": { "Download": "https://github.com/justengel/qt_multiprocessing/archive/v0.0.7.tar.gz", "Homepage": "https://github.com/justengel/qt_multiprocessing" }, "release_url": "https://pypi.org/project/qt-multiprocessing/0.0.8/", "requires_dist": null, "requires_python": "", "summary": "Library to have other PySide/PyQt widgets run in a separate process while allowing communication with the main process.", "version": "0.0.8" }, "last_serial": 4712462, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "d874a7628c86c61130f653e9ca5de5f3", "sha256": "dbdcf78e3a612cda963097eb1019d4188d195643ed0a4c5b9b02f2ac4dc04698" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d874a7628c86c61130f653e9ca5de5f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8965, "upload_time": "2018-07-23T20:59:54", "url": "https://files.pythonhosted.org/packages/69/47/1621d322cba63fd4100b2943cfdeca6e092d2ce28b74eec2969dd2725ae0/qt_multiprocessing-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "f075720c69a835245d1c1378f427e3dd", "sha256": "cf7441fde9af53163c5ccb8c14bd1f02d29b91eeaa346aa9cfad19cd417929ee" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.2.tar.gz", "has_sig": false, "md5_digest": "f075720c69a835245d1c1378f427e3dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8876, "upload_time": "2018-07-24T17:06:07", "url": "https://files.pythonhosted.org/packages/00/d6/330f015ffa06dff5a9b24bb41560e6cbb30315ad15dcd8414cc57529484d/qt_multiprocessing-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "bc9501e19ecedb070e3d3825836ff7bb", "sha256": "1b6a47fb023b95816cda6afc2e506be0c80ad86dd823e4b1cb06a4a4de2f8023" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.3.tar.gz", "has_sig": false, "md5_digest": "bc9501e19ecedb070e3d3825836ff7bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8871, "upload_time": "2018-07-26T13:53:10", "url": "https://files.pythonhosted.org/packages/88/cf/df6f1915438336c3b5ca21748dabacef99c012e19f845c17dd7c8f79320c/qt_multiprocessing-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "f3ef7a86fe53ef4df6c2a00f7f2c095f", "sha256": "bea4f1e073cb1d5113f18bd6034f221c7fa58607af6897de6e7edd4b4da0a802" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.4.tar.gz", "has_sig": false, "md5_digest": "f3ef7a86fe53ef4df6c2a00f7f2c095f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6681, "upload_time": "2018-07-26T17:49:11", "url": "https://files.pythonhosted.org/packages/02/cc/c7020f615ca25d0de2ba704de957346a047c8a7d036270c581485b891bda/qt_multiprocessing-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "975991cef24031dd8ff255f2b63c2909", "sha256": "83e5dfee2c9b83fbd4e75247b6db5187591e0b24e95e30ab6b662f14e3a4bf12" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.5.tar.gz", "has_sig": false, "md5_digest": "975991cef24031dd8ff255f2b63c2909", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6687, "upload_time": "2018-07-27T18:53:30", "url": "https://files.pythonhosted.org/packages/22/e8/06d8cdd5f150683a79700315012db83b3a4d6d652a41e0f508d3200f9961/qt_multiprocessing-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "0678d2af301195ba3de0d01f8af57f01", "sha256": "4ac3b9b99369af37acc296fb8cfc750007a62127f154a2c8a73c8e7f435b9e9e" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.6.tar.gz", "has_sig": false, "md5_digest": "0678d2af301195ba3de0d01f8af57f01", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6687, "upload_time": "2018-07-27T19:01:56", "url": "https://files.pythonhosted.org/packages/94/03/551e7afa09a8d3c7c1acf4987a66cfa80adb1143161e9096812b98715127/qt_multiprocessing-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "fdd10bf68887c6117d446638b341b7d4", "sha256": "7f03b812e632b17ddba980c1fd2cd897f3a538035f850b1e2ac6aff1324940c3" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.7.tar.gz", "has_sig": false, "md5_digest": "fdd10bf68887c6117d446638b341b7d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6707, "upload_time": "2018-09-04T13:54:57", "url": "https://files.pythonhosted.org/packages/df/a8/4155bfcd709c16dcf39b838085b91b2cf042fd7963f7f969647f2966ce49/qt_multiprocessing-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "3f4dba93227fcd12d5d9f91f26b696e9", "sha256": "097e63f24182a31b7ab8e329558f4f27d68caf7f2b5e07a2447bd5a7eb7d6a23" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.8.tar.gz", "has_sig": false, "md5_digest": "3f4dba93227fcd12d5d9f91f26b696e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6704, "upload_time": "2019-01-18T14:25:43", "url": "https://files.pythonhosted.org/packages/82/e0/9ae181b8f6255afbd5a086fc8661687ecebcbf08fccbebf92601ee18f322/qt_multiprocessing-0.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3f4dba93227fcd12d5d9f91f26b696e9", "sha256": "097e63f24182a31b7ab8e329558f4f27d68caf7f2b5e07a2447bd5a7eb7d6a23" }, "downloads": -1, "filename": "qt_multiprocessing-0.0.8.tar.gz", "has_sig": false, "md5_digest": "3f4dba93227fcd12d5d9f91f26b696e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6704, "upload_time": "2019-01-18T14:25:43", "url": "https://files.pythonhosted.org/packages/82/e0/9ae181b8f6255afbd5a086fc8661687ecebcbf08fccbebf92601ee18f322/qt_multiprocessing-0.0.8.tar.gz" } ] }