Skip to main content

PyThumbPad

PyPI version

PyThumbPad is a customizable virtual thumb pad for directional input, designed for use in Pygame projects. It features a central donut-shaped control area and a movable button pad, making it ideal for mobile games or any application requiring a thumb stick-style input.

Features

  • Customizable Appearance: Easily change colors and sizes for the donut and button pad.
  • Directional Input: Supports 4 or 8 directional quadrants for precise input.
  • Simple Integration: Easy to add to any Pygame project with minimal setup.
  • Responsive Input Handling: Smoothly tracks user input and updates the direction accordingly.

Installation using uv

If you are using a modern uv project, you can easily add py_thumbpad to your dependencies:

uv add py_thumbpad

Installation using PyPI

You can install the py_thumbpad package directly from PyPI using pip:

pip install py_thumbpad

Running the Demo / Local Development with uv

If you clone the repository and want to run the demo or develop locally:

# Clone the repository
git clone https://github.com/kerodekroma/py-thumbpad.git
cd py-thumbpad

# Run the demo app instantly (uv will bootstrap the venv & dependencies automatically)
uv run main.py

Updating the PyThumbPad Package

If you installed the py_thumbpad package with pip and want to update it:

pip install --upgrade py_thumbpad

If you are using uv, you can update it with:

uv add --upgrade py_thumbpad

Usage

Here's a basic example of how to use PyThumbPad in your Pygame project:

from py_thumbpad import PyThumbPad, PY_THUMBPAD_Directions

# Initialize the thumbpad at position (400, 300)
thumbpad = PyThumbPad((400, 300), {})

# In your game loop
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        
        thumbpad.listen_events(event)
    
    # Check the direction the thumbpad is pointing to
    if PY_THUMBPAD_Directions.TOP in thumbpad.directions:
        print("Moving UP!")
    elif PY_THUMBPAD_Directions.BOTTOM in thumbpad.directions:
        print("Moving DOWN!")
    elif PY_THUMBPAD_Directions.LEFT in thumbpad.directions:
        print("Moving LEFT!")
    elif PY_THUMBPAD_Directions.RIGHT in thumbpad.directions:
        print("Moving RIGHT!")
    
    # Update and render the thumbpad
    thumbpad.update()
    thumbpad.render(screen)
    
    pygame.display.flip()

pygame.quit()

Options

When initializing PyThumbPad, you can pass a dictionary of options to customize the appearance and behavior:

  • quadrants: The number of directional quadrants (4 for up, down, left, right; 8 for diagonals as well). Default is 4.

  • donut_color: The color of the donut-shaped pad. Default is (123, 157, 243).

  • button_color: The color of the movable button pad. Default is (255, 255, 0).

  • donut_bg_color: The background color of the donut. Default is (0, 0, 0).

Example:

thumb_pad = PyThumbPad((400, 300), {
    "quadrants": 8,
    "donut_color": (200, 100, 100),
    "button_color": (100, 200, 100),
    "donut_bg_color": (50, 50, 50)
})

Methods

update() Updates the state of the button pad. This method should be called within the game loop.

render(screen) Renders the thumb pad on the provided Pygame surface.

listen_events(event) Handles Pygame input events and updates the thumb pad's state.

get_directions(current_angle) Returns the direction based on the current angle and the number of quadrants. This method is used internally by listen_events.

Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue to discuss any changes or improvements.

License

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

Metadata

Release files for py-thumbpad 1.0.8

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

Source distribution (sdist)

Source distribution for py-thumbpad 1.0.8
File Size Uploaded
py_thumbpad-1.0.8.tar.gz 61.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-thumbpad 1.0.8
File Interpreter ABI Platform
py_thumbpad-1.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 68.0 kB

Release files / py_thumbpad-1.0.8.tar.gz

Download URL py_thumbpad-1.0.8.tar.gz
Size 61.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5e9d6f4c5e144232f0277956e40d98319a2b6bfb75e4eae5124a85f7d123e15d
BLAKE2b-256 checksum
How to use checksums
67e1cd77283b2cb82121dc426c353d2b9d9ccc911648795491c45fbf1a377d10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 30, 2026.

Transparency log

Release files / py_thumbpad-1.0.8-py3-none-any.whl

Download URL py_thumbpad-1.0.8-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15a3388a20f61afae801ec6c9826acb6b79bf3710e1410158ef98e3dd5f0998c
BLAKE2b-256 checksum
How to use checksums
0ea106fcfc49b9a48c9ad8cb47c3402abf4767d59d75e00f8e2da450ca4ae958
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.8 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

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