{ "info": { "author": "s0lst1ce", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "

\n \n

\n\n# pigUI\n\npigUI is a GUI toolkit for [Pygame](https://www.pygame.org/news). It provides objects that enables anyone to easily implement a GUI into their game without having to modify their game logic in any major way.\n\n\u200b\tTo do this pigUI provides a set of widgets such as Labels and Buttons which are organized into Containers. Containers are like \"boxes\" into which you can put your widgets. All widgets must be contained in order to be displayed.\n\n\n\n## Quickstart\n\nTo demonstrate the how the library works, a `demo.py` example program has been made. In this quick preview we'll explain the principles used in the demo.\n\n### Setting up environment\n\nAlthough this won't be the case in bigger games the demo defines all widgets at the beginning of the program.\n\n```python\nimport pygame as pg\nfrom pigui import *\n\n#display\nWIDTH = 800\nHEIGHT = 600\npg.init()\nwindow = pg.display.set_mode((WIDTH, HEIGHT))\npg.display.set_caption(\"A Pygame GUI library by s0lst1ce\")\nclock = pg.time.Clock()\nrunning = True\n\n#env\ndispatcher = Dispatcher.get()\nc = Container.from_background(50, 10, os.path.join(\"..\", \"png\", \"windows\", \"Window\", \"win6.png\"))\nt = Label.from_background(os.path.join(\"..\", \"png\", \"button\", \"blank\", \"textbg1.png\"), text=\"Hello World!\", offset=(25, 0))\nc.add(t, 50, 16)\nentities = [c]\n```\n\nThe 11 first lines are just Pygame display setup, the interesting part comes after that. There are two objects that will be created with pigUI which aren't widgets. The first one is Dispatcher. This object will process all events for the library and will need to be integrated to the event loop. But more on that in the next section. Just remember that you need to call the `get()` classmethod on it.\n\nNext comes the Container. As explained earlier this is like a box into which the widgets will be put. Here we create it from a background image. The first two parameters represents the coordinates at which the container should be placed. This can be changed later on. Next comes the path to the background image to load. This can also be a Pygame Surface.\n\nFinally we create our widgets and add them the container. \n\n\n\n### The event loop\n\nTo function properly pigUI requires an event loop. Since almost every game has one anyways this shouldn't be a problem in most cases. If you already have one: don't worry. You'll only need to add one line. The event loop loop of the demo is the following:\n\n```python\ndef events():\n\t'''processes events'''\n\tglobal running\n\tglobal dispatcher\n\n\tpressed_keys = pg.key.get_pressed()\n\tevents = pg.event.get()\n\tfor event in events:\n\t\tif event.type == pg.QUIT or pressed_keys[pg.K_ESCAPE]:\n\t\t\trunning=False\n\n\tdispatcher.process(events)\n```\n\n\n\nAs you can see the only place where pigUI is involved is at the last lines. And that's really all that needs to be done event-wise. Supply all events which occurred this tick to the dispatcher's `process` method and you're done with it. This allows you to keep your logic readable and concise at the same time.\n\n\n\n### The main loop\n\nNow comes the core of every game: the main loop. Also called the game loop, this is where the game's logic happens. In the major part it exists to update the different objects your game is made of. pigUI uses it to update it's widgets. However to keep it simple and concise it was built in such way that you only need to call the `update` method of all your containers. They will themselves determine if their widgets need to be updated, how and when.\n\n```python\ndef update():\n\t'''ran each tick handles all modification based on occured events'''\n\tglobal entities\n\tfor entity in entities:\n\t\tentity.update()\n```\n\n\n\n### Rendering\n\nFinally the widgets and containers need to be rendered or you'll have done all this work for nothing. Once again this has been kept as simple as possible since you only need to call your containers' `draw` method. It takes a single parameter: the surface to draw the container to. This can be the display.\n\n```python\ndef render():\n\t'''handles the rendering'''\n\tglobal window\n\tglobal entities\n\twindow.fill(BLUE)\n\tfor e in entities:\n\t\te.draw(window)\n\n\tpg.display.flip()\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/s0lst1ce/pigUI", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pigUI", "package_url": "https://pypi.org/project/pigUI/", "platform": "", "project_url": "https://pypi.org/project/pigUI/", "project_urls": { "Homepage": "https://github.com/s0lst1ce/pigUI" }, "release_url": "https://pypi.org/project/pigUI/1.0.2a0/", "requires_dist": [ "pygame (>=2.0.0.dev3)" ], "requires_python": ">=3.7", "summary": "", "version": "1.0.2a0" }, "last_serial": 5963665, "releases": { "1.0.1a0": [ { "comment_text": "", "digests": { "md5": "b2cb9bcb717e98ce82bfa8f4a6c66c0a", "sha256": "13c19d06386bfcaba0f45417654e34cd39750bda0f616c5dca0940ac1fd61f74" }, "downloads": -1, "filename": "pigUI-1.0.1a0-py3-none-any.whl", "has_sig": false, "md5_digest": "b2cb9bcb717e98ce82bfa8f4a6c66c0a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 24693, "upload_time": "2019-10-08T20:26:33", "url": "https://files.pythonhosted.org/packages/d0/60/f0aee648d346d6871d0d39b62b7a0a13b7a26e65a106e0a3178f5a7eddca/pigUI-1.0.1a0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ba9aed16370ec1ceb1f4ebecddfedd7f", "sha256": "9bf45700341c5b651b39324d66f744bf6b22f44782a6d0045a2e02fccc5c8202" }, "downloads": -1, "filename": "pigUI-1.0.1a0.tar.gz", "has_sig": false, "md5_digest": "ba9aed16370ec1ceb1f4ebecddfedd7f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 9985, "upload_time": "2019-10-08T20:26:34", "url": "https://files.pythonhosted.org/packages/8f/e4/73abe207b1977354cfb2a193386f3c667d2516570891918c955ab1302813/pigUI-1.0.1a0.tar.gz" } ], "1.0.2a0": [ { "comment_text": "", "digests": { "md5": "a7a51dcf63c5af715af7cc619ac36401", "sha256": "a78075de9ab6866be7074a79b865fbbb5dc68005996180ba6660b8a0114160ad" }, "downloads": -1, "filename": "pigUI-1.0.2a0-py3-none-any.whl", "has_sig": false, "md5_digest": "a7a51dcf63c5af715af7cc619ac36401", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 24706, "upload_time": "2019-10-12T09:35:15", "url": "https://files.pythonhosted.org/packages/af/77/9b2bf77fa2e21fe898f62d0db78b07ef5cb5adcc3d8fb92639071fd644ba/pigUI-1.0.2a0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d144a807ccb8c6868ce909f7cc0bec3f", "sha256": "cdbf746f0582272122179f4aa59106d6e0bfd56646c2842318f052ac5ef29abf" }, "downloads": -1, "filename": "pigUI-1.0.2a0.tar.gz", "has_sig": false, "md5_digest": "d144a807ccb8c6868ce909f7cc0bec3f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 10011, "upload_time": "2019-10-12T09:35:17", "url": "https://files.pythonhosted.org/packages/38/4b/d11ec4aab65e47135a6decb287df54b1c03e25556667c62fad7dfd470ce2/pigUI-1.0.2a0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a7a51dcf63c5af715af7cc619ac36401", "sha256": "a78075de9ab6866be7074a79b865fbbb5dc68005996180ba6660b8a0114160ad" }, "downloads": -1, "filename": "pigUI-1.0.2a0-py3-none-any.whl", "has_sig": false, "md5_digest": "a7a51dcf63c5af715af7cc619ac36401", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 24706, "upload_time": "2019-10-12T09:35:15", "url": "https://files.pythonhosted.org/packages/af/77/9b2bf77fa2e21fe898f62d0db78b07ef5cb5adcc3d8fb92639071fd644ba/pigUI-1.0.2a0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d144a807ccb8c6868ce909f7cc0bec3f", "sha256": "cdbf746f0582272122179f4aa59106d6e0bfd56646c2842318f052ac5ef29abf" }, "downloads": -1, "filename": "pigUI-1.0.2a0.tar.gz", "has_sig": false, "md5_digest": "d144a807ccb8c6868ce909f7cc0bec3f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 10011, "upload_time": "2019-10-12T09:35:17", "url": "https://files.pythonhosted.org/packages/38/4b/d11ec4aab65e47135a6decb287df54b1c03e25556667c62fad7dfd470ce2/pigUI-1.0.2a0.tar.gz" } ] }