Skip to main content

pgex

A Python PyGame package extension.

Desription

Pgex is a package that will help you to create games with PyGame easier and more convenient. There is no longer any need to register the functionality of text fields, buttons and other widgets each time. Everything has already been done for you!

Installation

Package is uploaded on PyPI and can be downloaded through

pip install pgex

Link on PyPI: https://pypi.org/project/pgex/
GitHub Repository: https://github.com/IvanFoke/pgex

Usage

1. Text creation
Before you start creating any project on PyGame, you must initialize it. Use standard commands like screen creation and title setting.
All widgets in pgex are stored in pgex.widgets. For example, let's import Text widget. Pgex also describes a large number of different colors. They can be found in pgex.parameters.

import pygame as pg
from pgex.widgets import Text
from pgex.parameters import colors

pg.init()
screen = pg.display.set_mode((800, 600))
pg.display.set_caption("Pgex Example")
clock = pg.time.Clock()

txt = Text("SomeText", r'Crushez.ttf', 100, font_color=colors["dark_gray"], bg_color=colors["white"], border_width=1)

game = True
while game:
    for event in pg.event.get():
        if event.type == pg.QUIT:
            game = False
            break
    screen.fill(colors["light_blue"])
    txt.draw(screen, (100, 300))
    pg.display.update()
    clock.tick(30)

As you can see in the example, text widget is created with Text class. First 3 arguments are the text, the path to a font and the font size. Result of the work of this program:

python_RdNLxTmrXB

2. A Button that gets a value of an Entry field
Button and Entry are another widgets from pgex. They also can be imported from pgex.widgets.
A distinctive feature of the Button is the passing of a function into it through the action argument, which will be called when the user clicks on it.
The Entry requires the passing of PyGame events. This allows widget to intercept the data entered in the field. Field supports backspace key. To stop entering the text in field, you can press escape, enter, or simply click the left mouse button outside the field.

from pgex.widgets import Button
from pgex.widgets import Entry


def get_entry_value():
    global entry
    print(f"Got text: {entry.text}")


entry = Entry(200, 50, r'Crushez.ttf', 20, centralized=True)
btn = Button(200, 100, "Btn", r'Crushez.ttf', 40, r'button.wav', action=get_entry_value, centralized=True)

def handle_events(events):
    for event in events:
        if event.type == pg.QUIT:
            return False
    return True

# ... in game cycle
while True:
    # ...
    events = pg.event.get()
    if not handle_events(events):
        break
    btn.draw(screen, (500, 100))
    entry.draw(screen, (100, 200), events)      

Result:
python_cr2iYoWarZ

Full example can be seen in examples folder.
All other possibilities will be described soon.

Metadata

Release files for pgex 0.4.4

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

Source distribution (sdist)

Source distribution for pgex 0.4.4
File Size Uploaded Provenance Actions
pgex-0.4.4.tar.gz 9.1 kB Without provenance Details for pgex-0.4.4.tar.gz

Built distribution (wheel)

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

Total release size: 20.5 kB

Release files / pgex-0.4.4.tar.gz

Download URL pgex-0.4.4.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b53ffb0e1a6a792e6f9db1ee717108b2b42d39b4ae37089d321c5d9bf0ce8629
BLAKE2b-256 checksum
How to use checksums
f68bb20c3efa0ed852aef653d9f1f92095a43528971e05efe7ca0802dfa823b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.5

Release files / pgex-0.4.4-py3-none-any.whl

Download URL pgex-0.4.4-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df657d694c2da849030bbaafb3b0f4559d00be88a74e92b34a75a3cb0ef5e1ca
BLAKE2b-256 checksum
How to use checksums
fde706d91d18d634e362e42b753bb79334f167c9ed5d32b0c5178704c82204ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.5

Security for pgex 0.4.4

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