Skip to main content

A GUI module compatible with pygame

Project description

PyGameUI

PyGameUI (or pgui) is a Python library for creating simple GUIs in pygame

Installation

Use the package manager pip to install PyGameUI.

pip install pgui

You can also install from source this way:

python setup.py install

Usage

PyGameUI widgets need a parent class with a screen attribute of type pygame.Surface and a pygame event listener to be used. This is a simple working example:

import pgui
import pygame

pygame.init()


class Main:
    def __init__(self):
        # Create a screen attribute
        self.screen = pygame.display.set_mode((600, 600))
        self.entry = pgui.Entry(self)
        self.button = pgui.Button(self, func=self.print_text)

        self.entry.move(50, 50)
        self.button.move(50, 100)

        self.widgets = [self.entry, self.button]

    def print_text(self):
        print(self.entry.text)

    def update(self):
        self.screen.fill((60, 60, 60))
        for w in self.widgets:
            w.update()
        pygame.display.flip()

    def events(self):
        pygame.event.wait()


main = Main()
while True:
    main.update()
    main.events()

Documentation

You can read the documentation here

Development

This module is still being developed, and it may be unstable or buggy.

ChangeLog

You can see the change logs here

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pgui, version 0.0.33
Filename, size File type Python version Upload date Hashes
Filename, size pgui-0.0.33.tar.gz (12.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page