Skip to main content

An object oriented python library for building user interfaces based on pygame

Project description

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, MenuBar, Menu, Action, MenuSeparator, HorizontalLayout, ImageBox
# ===== 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):
        self.paused = True

    def slider_updated(self, val):
        self.t = self.clip.duration*val
        self.paused = False

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

Project details


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.3.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

OOPyGame-0.0.3-py3-none-any.whl (39.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: OOPyGame-0.0.3.tar.gz
  • Upload date:
  • Size: 20.5 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.3.tar.gz
Algorithm Hash digest
SHA256 b49798b61c99e292152783c6e3f4ed8cf378814409f6435b0cca95c9c4a27d5c
MD5 e6754dd5ce5c2ad2b6b5c6ecc42dbb35
BLAKE2b-256 58efba7295ba9d727edb193c1e03e2317941f9b968eafb78e8c5e368921300a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: OOPyGame-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 39.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a1f0275e7539082e31e6022978f65321574c4831f75ac8fd26051c25244c691
MD5 2f7c3a0ce4d7efc2a1117c7ef3b0b905
BLAKE2b-256 f2ddf73730d3e12b2d4da2e787f1ae98bab80d7551cce29ab4aad9323d76e932

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page