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, 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()
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.4.tar.gz
(20.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
OOPyGame-0.0.4-py3-none-any.whl
(39.6 kB
view details)
File details
Details for the file OOPyGame-0.0.4.tar.gz.
File metadata
- Download URL: OOPyGame-0.0.4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
222f805a78fbf104fca9edf17d14437c00a9daaa51a8b1a65b0fe2b675597c14
|
|
| MD5 |
9e2763ecb9629b3d279aa161c3235e60
|
|
| BLAKE2b-256 |
95130db3e2a7c929e0ebc1c73a3894da7ae8507a667a56b77f6bb182d5c66eaa
|
File details
Details for the file OOPyGame-0.0.4-py3-none-any.whl.
File metadata
- Download URL: OOPyGame-0.0.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4de1dda795841bf8f0e29b9a2a2b91d7460ee57955b5e2923857d186f2e37e00
|
|
| MD5 |
0d93fdfe076a02d2e9b56f6ec031c778
|
|
| BLAKE2b-256 |
0c6e8def2c7dfca7bdc1187d7b58f8a4d2db1af032941c367117ae773c1a0cad
|