A GUI framework for pygame
Project description
🚧 WORK IN PROGESS 🚧
PyGameDUI - Declarative UI Framework for Pygame
PyGameDUI is a declarative UI framework for Pygame applications. It allows you to create complex user interfaces using a clean, nested class syntax.
Features
- Declarative Syntax: Define your UI layout using nested classes
- Responsive Layouts: Stack and grid layouts that adapt to window resizing
- Anchoring System: Position elements with anchor system
- Component-Based: Create reusable UI components
- Event Handling: Automatic event propagation to the UI elements
Installation
pip install pygamedui
Quick Example
Here's a simple example of creating a game menu:
import pygame
from pygamedui import Container, StackLayout, Label, Button, StackDirection, Anchor
class GameMenu(Container):
"""Example game menu using declarative syntax."""
width = 600
height = 400
background_color = (30, 30, 40)
class HeaderLayout(StackLayout):
direction = StackDirection.VERTICAL
spacing = 10
anchor = Anchor.TOP_CENTER
relative_width = 0.8
height = 120
margin = 20
class Title(Label):
text = "GAME TITLE"
font_size = 48
color = (220, 220, 100)
class Subtitle(Label):
text = "Subtitle of the game"
font_size = 24
color = (180, 180, 180)
class MenuLayout(StackLayout):
direction = StackDirection.VERTICAL
spacing = 15
anchor = Anchor.CENTER
relative_width = 0.5
relative_height = 0.4
class NewGameButton(Button):
text = "New Game"
hover_color = (20, 60, 160)
class ContinueButton(Button):
text = "Continue"
hover_color = (20, 60, 160)
class SettingsButton(Button):
text = "Settings"
hover_color = (20, 60, 160)
class QuitButton(Button):
text = "Quit"
hover_color = (20, 60, 160)
# Initialize pygame and create window
pygame.init()
screen = pygame.display.set_mode((800, 600), pygame.RESIZABLE)
pygame.display.set_caption("PyGameDUI Example")
# Create the UI with just one line!
ui = GameMenu()
ui.resize(screen.get_width(), screen.get_height())
# Main game loop
clock = pygame.time.Clock()
running = True
while running:
dt = clock.tick(60) / 1000.0
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.VIDEORESIZE:
width, height = event.size
screen = pygame.display.set_mode((width, height), pygame.RESIZABLE)
ui.resize(width, height)
else:
ui.handle_event(event)
ui.update(dt)
ui.render(screen)
pygame.display.flip()
pygame.quit()
Documentation
See detaile DOCUMENTATION.md file and examples directrory for more detailed guidance.
License
PyGameDUI is released under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file pygamedui-0.0.1.tar.gz.
File metadata
- Download URL: pygamedui-0.0.1.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0f5dcb889e2fc37e8ec9b6966dd2819e44ebc1bbf3051a2ec4b0ede98e11e59
|
|
| MD5 |
3f51b02b4b0e6e4cdab92bd5fdbc29cd
|
|
| BLAKE2b-256 |
6fdecd0f39e6da887368260b0b4baeae9c07f6cf9ff85370f53eb4a52e983122
|
File details
Details for the file pygamedui-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pygamedui-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03ebef7186af006e9d9a09e0a650dc03cba1f6e7f3c5b5df0fd2ff3528114816
|
|
| MD5 |
32ffff3fd9a96fa5e8fdf550505c055b
|
|
| BLAKE2b-256 |
d5c254fc1dbc717265c70dfbb3d64b197ed6b7399407e855b3b85c3b3e5111c8
|