{ "info": { "author": "ti250", "author_email": "ti250@cam.ac.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# NotificationCenter\n\nThis package implements a class similar to NSNotificationCenter, a variant of the Observer design pattern, from Objective-C and Swift in Python. To install, (soon you will be able to) just use \n\n\tpip install notificationcenter\n\nIt consists of one singleton class, NotificationCenter, that is used to add observers and to post notifications. To add an observer, you need to do the following:\n\n```python\nfrom notificationcenter import *\n\n# Get the NotifiationCenter\nnotificationcenter = NotificationCenter()\n# Define the function you want to perform when you get the notification.\n# It should have parameters of (sender, notification name, notification info)\n# And return nothing (It can, but it will be thrown away)\ndef foo(sender, notification_name, info):\n\t# Do something\n# Add an observer\nobserver = notificationcenter.add_observer(with_block=foo,\n\t\t\t\t\t\t\t\t\t\t for_name=\"bar\")\n```\n\nNow, if we post a notification to the NotificationCenter with the name \"bar\", as follows, the above function foo will be executed.\n\n```python\nnotificationcenter = NotificationCenter()\nnotificationcenter.post_notification(sender=None,\n\t\t\t\t\t\t\t\t\twith_name=\"bar\")\n```\n\nWhen you are no longer using the observer, you should remove it from the NotificationCenter so that the block is no longer executed. It is done as follows:\n\n```python\nnotificationcenter.remove_oberver(observer)\n```\n\nDetailed documentation is shown below, and the source code is commented.\n\n## API Reference\n\n### add\\_observer(with\\_block, for\\_name, for\\_sender=None)\n\nAdds an observer to listen for certain types of notifications.\n\n#### Parameters:\n\n* with\\_block: Some function that takes arguments of a sender (any object), notification name (string), and notification info (any object). Any values with\\_block returns will be ignored.\n\t* The function that will be executed when a notification with this name/sender is observed\n\n* for\\_name: String\n\t* The name of the notification for which the observer is registered.\n\n* for\\_sender: Any object\n\t* If this is set, then only notifications from this object are recieved. Else, any notifications with the correct name will be recieved.\n\n#### Returns:\n\n* tuple (String, Any Object, Some Function)\n\t* This is a tuple of (for\\_name, for\\_sender, with\\_block). It is not meant to be used directly except in the remove\\_observer method.\n\n### remove\\_observer(observer)\n\nRemoves the given observer from the list of active obserers.\n\n#### Parameters:\n\n* observer: tuple (String, Any Object, Some Function)\n\t* This is the tuple that is returned by add\\_observer.\n\n### post\\_notification(sender, with\\_name, with\\_info=None)\n\nPosts a notification with a given name and (optionally) some additional information.\n\n#### Parameters:\n\n* sender: Any Object\n\t* The sender of this notification\n\n* with\\_name: String\n\t* The name of the notification\n\n* with\\_info: Any Object\n\t* Any additional information for the notification", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "notifications observer", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "notificationcenter", "package_url": "https://pypi.org/project/notificationcenter/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/notificationcenter/", "project_urls": null, "release_url": "https://pypi.org/project/notificationcenter/1.0.0b2/", "requires_dist": null, "requires_python": "", "summary": "Port of NSNotificationCenter functionality to Python", "version": "1.0.0b2" }, "last_serial": 2282275, "releases": { "1.0.0b1": [ { "comment_text": "", "digests": { "md5": "f71530753e53d59cb1f4b7695da1eadc", "sha256": "38daea100ecf90e654dc397c549c119a490a06b1d3779ce735ca9b92f69fbabd" }, "downloads": -1, "filename": "notificationcenter-1.0.0b1-py3-none-any.whl", "has_sig": false, "md5_digest": "f71530753e53d59cb1f4b7695da1eadc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6366, "upload_time": "2016-08-15T07:32:07", "url": "https://files.pythonhosted.org/packages/93/1f/15256c37ddd8ec4610015cfc0c49ce597b43ddddc49109b5c8afe843a5f5/notificationcenter-1.0.0b1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d054fe083c3378cebd3258903b85a28b", "sha256": "e3fcdd5a607a057a08d8f5ef4e3adf015b88b8291d4e7da58b6988d7480a7f5e" }, "downloads": -1, "filename": "notificationcenter-1.0.0b1.tar.gz", "has_sig": false, "md5_digest": "d054fe083c3378cebd3258903b85a28b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20042, "upload_time": "2016-08-15T07:32:08", "url": "https://files.pythonhosted.org/packages/e5/73/1e4839cf691024058ce72e1bee427f536ec6ad5bc93b5dc5952a34981946/notificationcenter-1.0.0b1.tar.gz" } ], "1.0.0b2": [ { "comment_text": "", "digests": { "md5": "c9d864de088b2f0ecd86af8df3e1e727", "sha256": "f911d87bf45d723bd4996f98237ac5ddb424ab17dd32a18f375e05e9e87a6406" }, "downloads": -1, "filename": "notificationcenter-1.0.0b2-py3-none-any.whl", "has_sig": false, "md5_digest": "c9d864de088b2f0ecd86af8df3e1e727", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6362, "upload_time": "2016-08-15T14:44:51", "url": "https://files.pythonhosted.org/packages/a9/fa/ccd3c4f8f4c9516a12e1da643b67d8c3aad8226ccbe2f4ccf95d14b40377/notificationcenter-1.0.0b2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce4a32d4e172edf5b0d424f5e9f23447", "sha256": "481e9c9c379e0f86d861c60ed6ee5558f46f7de06ce0edd4cf7bdba54687f7a2" }, "downloads": -1, "filename": "notificationcenter-1.0.0b2.tar.gz", "has_sig": false, "md5_digest": "ce4a32d4e172edf5b0d424f5e9f23447", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20041, "upload_time": "2016-08-15T14:44:53", "url": "https://files.pythonhosted.org/packages/75/63/995c2c49bef3e44a33f890e2e74381edf99f98b178eb4e619dcdeb642476/notificationcenter-1.0.0b2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c9d864de088b2f0ecd86af8df3e1e727", "sha256": "f911d87bf45d723bd4996f98237ac5ddb424ab17dd32a18f375e05e9e87a6406" }, "downloads": -1, "filename": "notificationcenter-1.0.0b2-py3-none-any.whl", "has_sig": false, "md5_digest": "c9d864de088b2f0ecd86af8df3e1e727", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6362, "upload_time": "2016-08-15T14:44:51", "url": "https://files.pythonhosted.org/packages/a9/fa/ccd3c4f8f4c9516a12e1da643b67d8c3aad8226ccbe2f4ccf95d14b40377/notificationcenter-1.0.0b2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce4a32d4e172edf5b0d424f5e9f23447", "sha256": "481e9c9c379e0f86d861c60ed6ee5558f46f7de06ce0edd4cf7bdba54687f7a2" }, "downloads": -1, "filename": "notificationcenter-1.0.0b2.tar.gz", "has_sig": false, "md5_digest": "ce4a32d4e172edf5b0d424f5e9f23447", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20041, "upload_time": "2016-08-15T14:44:53", "url": "https://files.pythonhosted.org/packages/75/63/995c2c49bef3e44a33f890e2e74381edf99f98b178eb4e619dcdeb642476/notificationcenter-1.0.0b2.tar.gz" } ] }