Skip to main content

An easy-to-use extension to the very well-known package Pygame.

Project description

MyUI

A lightweight and intuitive extension for Pygame, designed to simplify UI development.


🚀 Features

UI Components – Ready-to-use buttons, sliders, and more.
Plugin System – Easily extend functionality using modular plugins.
Event Stack – Simplifies repeated or custom event handling.
Layering System – Clean separation of background, normal, and top-level UI layers.
Built for Games and Tools – Seamless integration into Pygame-based projects.


📦 Installation

Install MyUI via PyPI:

pip install MyUI_pygame

⚡ Quick Start

import MyUI
import pygame

# Load music
pygame.mixer.music.load("music.mp3")
pygame.mixer.music.play(-1)

# Initialize app
WIDTH, HEIGHT = 800, 600
app = MyUI.App((WIDTH, HEIGHT))
pygame.display.set_caption("Simple MyUI Demo")

# Load plugins from folder
plugin_wrappers = MyUI.load_plugins_from("plugins")

# Handle plugins before loading
main_group = MyUI.plugins.create_dict(MyUI.plugins.get_plugin_group(plugin_wrappers, "plugin"))
entry = main_group.get("plugin-entry")
print(entry.name)

# Create a reload method
def reload_plugins():
    global plugin_wrappers
    plugin_wrappers = MyUI.load_plugins_from("plugins")
    app.reload(plugin_wrappers)

# Load fonts
fonts = MyUI.FontScheme(
    small1=pygame.font.SysFont("consolas", 15)
)

# Create a button
button = MyUI.PushButton(
    text="Reload!",
    font=fonts.small1,
    pos=(50, 50),
    size=(100, 30),
    color=(50, 50, 150),
    hover_color=(70, 70, 170),
    callback=reload_plugins
)

# Create a surface
surf = MyUI.Surface(
    pos=(100, 50),
    size=(200, 200),
    background_color=(200, 200, 250),
    border_color=(225, 225, 255),
    border_width=2,
    border_radius=5
)

# Add UI elements to the top layer
surf.add_handler(button.render, button.handle_event)
app.add_top(surf.render, surf.handle_event)

# Attach plugins
app.load_plugins(plugin_wrappers)

# Run the app
app.run()

ℹ️ Additional Information

  • Plugin folder: Make sure the plugins directory exists and contains valid plugin files.
  • Styling: MyUI.FontScheme allows you to manage multiple fonts with ease. This also applies for coloring, MyUI.Theme.
  • Surface layering: Use add_background, add_normal, and add_top to control UI rendering layers.
  • Reloading: The app supports hot-reloading of plugins through custom callbacks.
  • Audio: Compatible with Pygame's sound and music systems.

--

📜 License

This project is licensed under the MIT License.

⭐ Like This Project?

If you find this project useful, consider starring it on GitHub and contributing to its development. Your support helps keep it active and growing! 🚀

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

myui_pygame-1.0.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

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

MyUI_pygame-1.0.0-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file myui_pygame-1.0.0.tar.gz.

File metadata

  • Download URL: myui_pygame-1.0.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for myui_pygame-1.0.0.tar.gz
Algorithm Hash digest
SHA256 502a746996baedea2bbf17983e5b08b941aeaae38caaed151890813a1a57e0bc
MD5 5d73f11a905211718c2edcbc5045efff
BLAKE2b-256 e8da99e3db0b9075e331010101ee9349372cb1a6dddcf008f36ea2e0571bf21a

See more details on using hashes here.

File details

Details for the file MyUI_pygame-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: MyUI_pygame-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for MyUI_pygame-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ce4312c5f2a2551bc7850dd49e3ce09a7b4a62da896154940a2b900f481ebd4
MD5 442fa4761c9ca9ea61b2155707dc528f
BLAKE2b-256 d1da1485eda622bc5c6a01113532f9e49c2d8c2c5fe84c8462559a4f3197bd8c

See more details on using hashes here.

Supported by

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