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, screen management and much more.

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 button
button = epw.Button(text="Click Me!")
button.place(300, 100)

# create a slider
slider = epw.Slider(text="Volume", start=0, end=100, auto_size=False, width=300)
slider.place(300, 200)

# create a text entry
entry = epw.Entry(placeholder_text="Type here...", auto_size=False, width=250)
entry.place(300, 400)


def draw():
   window.fill((30, 30, 30))


# main game loop
running = True
while running:
    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(draw)

    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 or show text.

example code

Surface (images etc.)

This converts your pygame surfaces into an easypygamewidgets widget that can be used in screens. (All pygame surface commands can be applied to the "surface" attribute of your widget.)

example code

Timekeeper

A text display that can show a timer or stopwatch.

example code

Tooltips

A text display that is only shown when you hover over a widgets.

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
  5. bindings - binding events to widgets

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-26.12.2.tar.gz (677.5 kB view details)

Uploaded Source

Built Distribution

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

easypygamewidgets-26.12.2-py3-none-any.whl (692.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for easypygamewidgets-26.12.2.tar.gz
Algorithm Hash digest
SHA256 61ee0524cc54dc98b2f9ee45873b1c869ccd782d13714b2ab29140e8bd9c2bc8
MD5 974217a0faeca8d5ac4fb7006516afd8
BLAKE2b-256 93ae0bb0d28aacc9c71117d4b50d79d0f371c5c72b249d573a67b87a875c8516

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for easypygamewidgets-26.12.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2bd93528c242f24d1c7c28790bdb36998b0d38e0523e6e254d62601a2036b0e6
MD5 884928af0ee35d3de1828b6331959cf4
BLAKE2b-256 12e659f862d6f0a7df343933732bff0523347e34db763fa588ededf152ed12bf

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