Skip to main content

PygameUIKit

Small UI widgets for Pygame: buttons, sliders, dropdowns, text inputs, labels, and animated bar charts. You control the layout; the kit handles interaction and drawing.

Requires Python 3.11+ (tested through 3.15). Uses pygame-ce, which provides the familiar import pygame API. Use a fresh environment when upgrading from classic pygame; the two packages share the same import name.

Install

uv add PygameUIKit

Or use pip install PygameUIKit.

Try it

With uv installed:

git clone https://github.com/Times0/PygameUIKit.git
cd PygameUIKit
uv run pygameuikit-demo

uv installs Python and dependencies automatically. The demo is also included in the installed package: pygameuikit-demo or python -m PygameUIKit.demo.

Use it

import pygame
from PygameUIKit import Group, button

pygame.init()
screen = pygame.display.set_mode((640, 360))
clock = pygame.time.Clock()
ui = Group()
hello = button.ButtonText(
    "Say hello",
    lambda: print("Hello!"),
    rect_color=(85, 145, 92),
    border_radius=8,
    ui_group=ui,
)

running = True
while running:
    dt = clock.tick(60) / 1000
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        else:
            ui.handle_event(event)
    if not running:
        break
    ui.update(dt)
    screen.fill((30, 32, 36))
    hello.draw(screen, 240, 150)
    pygame.display.flip()

pygame.quit()

Add widgets with ui_group=ui, forward each event once, and call ui.update(dt) with seconds. Draw each widget at your chosen position. Sliders accept draw(screen, x, y, width, height); charts use the same layout arguments. Draw dropdowns last so their menus appear above other widgets.

  • button: text, image, icon, toggle, and thread-status buttons.
  • slider.Slider(min, max, step): get_value() and connect(callback).
  • combobox.ComboBox(["One", "Two"]): get_value() and add_action(index, callback).
  • text_input.TextInput(placeholder="Name"): get_text() and set_text(text).
  • label.Label("Hello", "white"): update the text property.
  • barchart.BarChart([10, 20, 30]): change_value(index, value); accepts non-negative values.

Text inputs use Pygame's TEXTINPUT events for Unicode text and KEYDOWN for editing. Forward both through Group; don't also forward the same events separately to the input. Pass a custom pygame.font.Font if you need a particular font or character set.

Develop

uv sync --locked
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv build

Tests use SDL's dummy drivers and don't need a display. CI checks Python 3.11–3.15 on Linux and Python 3.15 on Windows and macOS. See RELEASING.md for publishing.

MIT licensed. Contributions welcome.

Metadata

Release files for PygameUIKit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PygameUIKit 0.2.0
File Size Uploaded Provenance Actions
pygameuikit-0.2.0.tar.gz 19.9 kB Without provenance Details for pygameuikit-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PygameUIKit 0.2.0
File Interpreter ABI Platform Actions
pygameuikit-0.2.0-py3-none-any.whl Python 3 none any Details for pygameuikit-0.2.0-py3-none-any.whl

Total release size: 40.9 kB

Release files / pygameuikit-0.2.0.tar.gz

Download URL pygameuikit-0.2.0.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bd9d674a341f77de0abe18d42a39dafc982109b8ca1b95132caa09f4dd60558c
BLAKE2b-256 checksum
How to use checksums
f052e62e1eed37807e11054c4daa5491e0af8026b8f339f0dd9ae3c5b37169a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pygameuikit-0.2.0-py3-none-any.whl

Download URL pygameuikit-0.2.0-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f225708ecefecc22f48d952533dfa486447c0c811d7ad81d46840647c1af46e
BLAKE2b-256 checksum
How to use checksums
8c5bc45e0b32ae8f7fec0bebc6fb82ee2714552359e6087aeee283995e823964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for PygameUIKit 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page