{"id":16810951,"url":"https://github.com/johnf/pygamegui","last_synced_at":"2025-03-17T10:41:42.051Z","repository":{"id":5411195,"uuid":"6601830","full_name":"johnf/PygameGUI","owner":"johnf","description":"A python module for easy, fast, customisable GUIs using pygame","archived":false,"fork":false,"pushed_at":"2012-11-08T19:28:35.000Z","size":112,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T20:14:28.874Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mattyb149/pentaho-plugin-skeletons","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-08T19:26:02.000Z","updated_at":"2016-03-03T02:55:37.000Z","dependencies_parsed_at":"2022-09-06T16:02:17.197Z","dependency_job_id":null,"html_url":"https://github.com/johnf/PygameGUI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnf%2FPygameGUI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnf%2FPygameGUI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnf%2FPygameGUI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnf%2FPygameGUI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnf","download_url":"https://codeload.github.com/johnf/PygameGUI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244018907,"owners_count":20384655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T10:17:13.296Z","updated_at":"2025-03-17T10:41:42.032Z","avatar_url":"https://github.com/johnf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Python GUI Module\n===\n\nA Pygame built GUI Library based on the GUI interface of Unity 3d\nIt allows for very fast, easy but also customisable usage.\n\n## Installation\n\nInstall Pygame\n\n## Documentation\n\n### Making a Skin\n\nSkins are objects that hold all relavent information for rendering the GUI\nThe first 3 parameters are the names of the images relevant for rendering:\nNormal texture, Over Texture and the Down texture\nThe 4th parameter represents the font used in rendering\nThe last parameter is for an optional border defaulted to 0.\nEach GUI element will have a border with this value on every side.\n\n```python\nimport pygame, GUI\n\nskin = GUI.Skin(\"Normal.png\", \"Over.png\", \"Down.png\", pygame.font.Font(None, 16), 5)\n```\n\n### Initializing the GUI\n\nPygameGUIAIP's init method can be used as a quick way of starting off Pygame and a window,\nAs well as setting the default look of the GUI.\nThe first parameter is a touple containing the width and height of the screen.\nThe second is a optional setting for the default skin, as a `GUI.Skin`.\nThe last is an optional parameter for fullscreen, defaulted to `False`.\nThis function returns a `pygame.Surface` for the screen.\n\n```python\nimport pygame, GUI\n\nskin = GUI.Skin(\"Normal.png\", \"Over.png\", \"Down.png\", pygame.font.Font(None, 16), 5)\nscreen = GUI.init((800, 487), skin, True)\n```\n\n### Every Update\n\nEvery frame all relevant GUI functions have to be called.\nFor the next part of the documentation I assume all the code is called every frame.\n\n### Clear the screen\n\nPygameGUI allwos you to quickly clear the screen with a single call.\nThe first parameter is the `pygame.Surface` of the screen or other area to clear.\nThe second parameter is the color to clear to.\n\n```python\nGUI.Clear(screen, pygame.Color(\"Black\"))\n```\n\n### A simple Box\n\nThe most simple part of a GUI is a box with some text.\nPygameGUI makes it easy.\nThe first parameter is a `pygame.Rect` for positiong and scaling of the Box.\nThe second parameter is the text displayed in the box.\nThe last parameter is an optional skin parameter, overwriting the use of default skin on this box only.\n\n```python\nGUI.Box(pygame.Rect(0, 0, 100, 50), \"Hello World\", skin=other_skin)\n```\n\n### The usefull Button\n\nThe most usefull feature in a GUI engine is a simple Button.\nJust like a Box, it iis very easy to use with as much customisation as you want.\nThe first three parameters are exactly the same as a box.\nThe fourth one is the mouse button which should be pressed to activate the box as an integer, defaulted to 0.\nThe fith is an optional state the button should be locked at, default is -1. 0 is for normal look, 1 is for over look, 2 is for down look.\nThis function returns a boolean weather the button was pressed.\n\n```python\nif (GUI.Button(pygame.Rect(0, 0, 100, 50), \"Hi!\", skin=other_skin, type=0)):\n  GUI.Button(pygame.Rect(0, 50, 100, 50), \"Down\", state=2)\n```\n\n### Repeatable Button\n\nExactly the same as a button, only it returns true even if it is held down.\n\n```python\nif (GUI.Button(pygame.Rect(posx, posy, 100, 50), \"Movable\")):\n  posx = pygame.mouse.get_pos()[0]\n  posy = pygame.mouse.get_pos()[1]\n```\n\n### An Input Box (Text Field)\n\nWhat is a GUI Library without an input box?\nThe first parameter is the same as a box.\nThe second parameter is the current text in the box.\nThe third parameter is a boolean for the text field being active or not.\nthe fourth parameter is the same as a button, the type of mouse button to activate the text field.\nThis function returns 2 parameters, the new text and the new focus variables.\n\n```python\nfield_text, field_active = GUI.TextField(pygame.Rect(0, 0, 100, 50), field_text, field_active, type=0)\n```\n\n### Just some text (Label)\n\nThis is exactly the same as a Box, just without the box.\nParameters are also the same.\n\n```python\nGUI.Label(pygame.Rect(0, 0, 100, 50), \"Hello World\")\n```\n\n### The power of a Selection Gid\n\nWhat if you wanted to only select one item in a gird and have it stay selected?\n`GUI.SelectionGid` allows you to do exactly that!\nThe first parameter is again a `pygame.Rect` every part of the grid is perfectly scaled.\nThe second parameter is the amount of boxes that should be horizontally.\nThe third parameter is the currently selected box as an index (integer).\nThe fourth parameter is a list of every string for every box. It also determines how many boxes there should be.\nThe last 2 parameters are from previous elements as well: override skin and mouse press type.\nThis function returns the currently selected grid index.\n\n```python\nselected = GUI.SelectionGid(pygame.Rect(0, 0, 300, 300), 2, selected, [\"1\", \"2\", \"3\", \"4\", \"5\"], skin=None, type=0)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnf%2Fpygamegui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnf%2Fpygamegui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnf%2Fpygamegui/lists"}