Skip to main content

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

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()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

OOPyGame-0.0.5.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

OOPyGame-0.0.5-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

Details for the file OOPyGame-0.0.5.tar.gz.

File metadata

  • Download URL: OOPyGame-0.0.5.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.7

File hashes

Hashes for OOPyGame-0.0.5.tar.gz
Algorithm Hash digest
SHA256 9e009052503bab6dcd22ab240d60f86f9718e6631848897007fe819394d41111
MD5 b241009ae7f8b49fffe281bb84bf46ef
BLAKE2b-256 40f18f98effc810a01e63b58dbc58d15fa393a59acfa452299c7f24154ee4a19

See more details on using hashes here.

File details

Details for the file OOPyGame-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: OOPyGame-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 40.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.7

File hashes

Hashes for OOPyGame-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3f7f1db1e6e44f37a8f2bf66411e6b921368db5ce0b9453ff52ea3c38e5dc404
MD5 f972cab35ef7a212c2fc5c322a15bd6d
BLAKE2b-256 7b15f93bd0426285bed3ce23b9b250e0ea36347aef006ef238d651c7ea4852eb

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 files

0.0.4

2 files

0.0.3

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page