OOPyGame


NameOOPyGame JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/ParisNeo/OOPyGame
SummaryAn object oriented python library for building user interfaces based on pygame
upload_time2022-01-30 21:02:52
maintainer
docs_urlNone
authorSaifeddine ALOUI
requires_python
license
keywords
VCS
bugtrack_url
requirements numpy pygame
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OOPyGame

Object oriented wrapper on pygame to simplify making UI for pygame applications.
Supported layouts:
- Absolute layout (default one)
- Horizontal layout
- Vertical layout

Supported widgets:
- Widget
- Button
- Label
- ImageBox
- Slider
- List
- MenuBar
- Menu
- Action

To use the library, import the windowmanager and the needed widgets from PyGameUI

```python
from OOPyGame import WindowManager, Button, List, MenuBar, Menu, Action, MenuSeparator, HorizontalLayout, VerticalLayout, ImageBox, Slider
import pygame
# ===== Build pygame window and populate with widgets ===================
pygame.init()
class MainWindow(WindowManager):
    def __init__(self):
        # Initialize the window manager
        WindowManager.__init__(self, "Face box", (800,600))
        self.mn_bar = self.build_menu_bar()
        self.file = Menu(self.mn_bar,"File")
        new = Action(self.file,"New")
        sep = MenuSeparator(self.file)
        quit = Action(self.file,"Quit")
        quit.clicked_event_handler = self.fn_quit
        self.edit = Menu(self.mn_bar,"Edit")

        self.layout_1 = HorizontalLayout()
        self.layout_2 = VerticalLayout()

        # Build an image Box
        self.main_video = ImageBox()

        # Build a slider
        self.time_slider = Slider()
        self.time_slider.value=0.5
        self.time_slider.valueChanged_callback = self.slider_updated
        self.time_slider.mouse_down_callback = self.slider_mouse_down

        # Build a list of items
        self.test_ui1 = List(list=[f"item {i}" for i in range(100)])
        self.test_ui3 = Button("Hello 3")

        self.layout_1.addWidget(self.test_ui1,0.2)
        self.layout_1.addWidget(self.layout_2,0.8)

        self.layout_2.addWidget(self.main_video,0.7)
        self.layout_2.addWidget(self.time_slider,0.05)

        self.layout_2.addWidget(self.test_ui3,0.25)

        self.addWidget(self.layout_1)

        # Build a timer that repeats every 1/24 secondes
        self.timer = self.build_timer(self.do_stuf,1/24)
        self.timer.start()

    def slider_mouse_down(self):
        # when the slider is pressed with mouse this callback is triggered
        pass

    def slider_updated(self, val):
        # When slider value changed this callback is triggered
        pass

    def do_stuf(self):
        # Here do something that will be executed every timer tick
        pass

    def fn_quit(self):
        self.Running=False

# =======================================================================

#
#clip.preview()
if __name__=="__main__":
    mw = MainWindow()
    mw.loop()
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ParisNeo/OOPyGame",
    "name": "OOPyGame",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Saifeddine ALOUI",
    "author_email": "aloui.saifeddine@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/40/f1/8f98effc810a01e63b58dbc58d15fa393a59acfa452299c7f24154ee4a19/OOPyGame-0.0.5.tar.gz",
    "platform": "",
    "description": "# OOPyGame\n\nObject oriented wrapper on pygame to simplify making UI for pygame applications.\nSupported layouts:\n- Absolute layout (default one)\n- Horizontal layout\n- Vertical layout\n\nSupported widgets:\n- Widget\n- Button\n- Label\n- ImageBox\n- Slider\n- List\n- MenuBar\n- Menu\n- Action\n\nTo use the library, import the windowmanager and the needed widgets from PyGameUI\n\n```python\nfrom OOPyGame import WindowManager, Button, List, MenuBar, Menu, Action, MenuSeparator, HorizontalLayout, VerticalLayout, ImageBox, Slider\nimport pygame\n# ===== Build pygame window and populate with widgets ===================\npygame.init()\nclass MainWindow(WindowManager):\n    def __init__(self):\n        # Initialize the window manager\n        WindowManager.__init__(self, \"Face box\", (800,600))\n        self.mn_bar = self.build_menu_bar()\n        self.file = Menu(self.mn_bar,\"File\")\n        new = Action(self.file,\"New\")\n        sep = MenuSeparator(self.file)\n        quit = Action(self.file,\"Quit\")\n        quit.clicked_event_handler = self.fn_quit\n        self.edit = Menu(self.mn_bar,\"Edit\")\n\n        self.layout_1 = HorizontalLayout()\n        self.layout_2 = VerticalLayout()\n\n        # Build an image Box\n        self.main_video = ImageBox()\n\n        # Build a slider\n        self.time_slider = Slider()\n        self.time_slider.value=0.5\n        self.time_slider.valueChanged_callback = self.slider_updated\n        self.time_slider.mouse_down_callback = self.slider_mouse_down\n\n        # Build a list of items\n        self.test_ui1 = List(list=[f\"item {i}\" for i in range(100)])\n        self.test_ui3 = Button(\"Hello 3\")\n\n        self.layout_1.addWidget(self.test_ui1,0.2)\n        self.layout_1.addWidget(self.layout_2,0.8)\n\n        self.layout_2.addWidget(self.main_video,0.7)\n        self.layout_2.addWidget(self.time_slider,0.05)\n\n        self.layout_2.addWidget(self.test_ui3,0.25)\n\n        self.addWidget(self.layout_1)\n\n        # Build a timer that repeats every 1/24 secondes\n        self.timer = self.build_timer(self.do_stuf,1/24)\n        self.timer.start()\n\n    def slider_mouse_down(self):\n        # when the slider is pressed with mouse this callback is triggered\n        pass\n\n    def slider_updated(self, val):\n        # When slider value changed this callback is triggered\n        pass\n\n    def do_stuf(self):\n        # Here do something that will be executed every timer tick\n        pass\n\n    def fn_quit(self):\n        self.Running=False\n\n# =======================================================================\n\n#\n#clip.preview()\nif __name__==\"__main__\":\n    mw = MainWindow()\n    mw.loop()\n```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "An object oriented python library for building user interfaces based on pygame",
    "version": "0.0.5",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b15f93bd0426285bed3ce23b9b250e0ea36347aef006ef238d651c7ea4852eb",
                "md5": "f972cab35ef7a212c2fc5c322a15bd6d",
                "sha256": "3f7f1db1e6e44f37a8f2bf66411e6b921368db5ce0b9453ff52ea3c38e5dc404"
            },
            "downloads": -1,
            "filename": "OOPyGame-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f972cab35ef7a212c2fc5c322a15bd6d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 40767,
            "upload_time": "2022-01-30T21:02:51",
            "upload_time_iso_8601": "2022-01-30T21:02:51.148744Z",
            "url": "https://files.pythonhosted.org/packages/7b/15/f93bd0426285bed3ce23b9b250e0ea36347aef006ef238d651c7ea4852eb/OOPyGame-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "40f18f98effc810a01e63b58dbc58d15fa393a59acfa452299c7f24154ee4a19",
                "md5": "b241009ae7f8b49fffe281bb84bf46ef",
                "sha256": "9e009052503bab6dcd22ab240d60f86f9718e6631848897007fe819394d41111"
            },
            "downloads": -1,
            "filename": "OOPyGame-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "b241009ae7f8b49fffe281bb84bf46ef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 21774,
            "upload_time": "2022-01-30T21:02:52",
            "upload_time_iso_8601": "2022-01-30T21:02:52.917290Z",
            "url": "https://files.pythonhosted.org/packages/40/f1/8f98effc810a01e63b58dbc58d15fa393a59acfa452299c7f24154ee4a19/OOPyGame-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-01-30 21:02:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ParisNeo",
    "github_project": "OOPyGame",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "pygame",
            "specs": []
        }
    ],
    "lcname": "oopygame"
}
        
Elapsed time: 0.20487s