Skip to main content

Create GUIs for pygame.

Project description

EasyPygameWidgets

An easy-to-use UI widget library for pygame, featuring customizable buttons, sliders, text entries, and screen management.

Features

  • easy integration: seamlessly works with existing pygame projects
  • customizable widgets: nearly infinite styling options for colors, sounds, cursors, and more
  • screen management: built-in screen system for creating different GUIs

Installation

Windows

pip install easypygamewidgets

Linux/macOS

python3 -m pip install easypygamewidgets

Quick Start

import pygame
import easypygamewidgets as epw

pygame.init()
window = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()

# link the pygame window
epw.link_pygame_window(window)

# create a screen (optional)
screen = epw.Screen(id="main")

# create a button
button = epw.Button(screen=screen, text="Click Me!", width=200, height=50)
button.place(300, 250)

# create a slider
slider = epw.Slider(screen=screen, text="Volume", start=0, end=100, width=300)
slider.place(250, 350)

# create a text entry
entry = epw.Entry(screen=screen, text="Type here...", width=250)
entry.place(275, 450)

# main game loop
running = True
while running:
    window.fill((30, 30, 30))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

        # handle widget events
        epw.handle_event(event)

    # handle special widget events
    epw.handle_special_events()

    # draw all widgets
    epw.flip()

    pygame.display.update()
    clock.tick(60)

pygame.quit()

Widgets Documentation

All examples will use the same start template code.

Screen

A container for managing groups of widgets with shared visibility and state.

example code

Button

A customizable button widget to run commands when interacted.

example code

Slider

A slider for selecting values within a specific range.

example code

Entry

A text entry with selection and clipboard support.

example code

Label

A text display that can be used to drag it into places.

example code

Module Functions

Core Functions

# link your pygame window (required before using widgets)
epw.link_pygame_window(pygame_window)

# handle pygame events (call in event loop)
epw.handle_event(pygame_event)

# handle special events (call outside event loop)
epw.handle_special_events()

# draw all widgets to the linked window
epw.flip()

Examples (COMING SOON)

Check the examples directory for complete working examples:

  1. all widgets example - simple demo of all widgets
  2. screens with animations - multiple screens with transitions
  3. settings screen - interactive settings panel with sliders
  4. login form - form with entries and validation

Requirements

  • python
  • pygame
  • requests (for update checking in background once)

I recommend using the latest version of libraries.

Contributing

Contributions are welcome! Please feel free to submit a pull request. Of course will be mentioned :)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support


Made with ❤️ by PizzaPost

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

easypygamewidgets-1.1.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

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

easypygamewidgets-1.1.0-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file easypygamewidgets-1.1.0.tar.gz.

File metadata

  • Download URL: easypygamewidgets-1.1.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for easypygamewidgets-1.1.0.tar.gz
Algorithm Hash digest
SHA256 97d7bf4c444c6fdcb02e7b35319e6874679deb66cd758d4ea8566a5c05b649c2
MD5 73fddb11b5e2aebd88874a9d23129e6b
BLAKE2b-256 0486acf0dfc2287577927a04afd17f9f22846e40717a84dcd17827b01da26476

See more details on using hashes here.

File details

Details for the file easypygamewidgets-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for easypygamewidgets-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3736a734070aacac135b44a8931e8c75fcb9e01f3e7d7b6848d869b7bc37296d
MD5 8a2ca2988c2a14c4649d3f00783b137a
BLAKE2b-256 2466a0e736f5aafa0616bb1ec6d04180bb315841f2024e7e62bff397bb0846ee

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