Skip to main content

Basic UI components for a Pygame environment.

Project description

peng-ui

Basic UI components for a Pygame environment.

Installation

pip install peng_ui

Basic Usage

You can subclass the Viewer class to create a custom UI very quickly.

import pygame as pg

from peng_ui.elements import TextField, EditField, Label, Button
from peng_ui.viewer import Viewer

class MyViewer(Viewer):
    def __init__(self):
        super().__init__(screen_size=(800, 600))
        self.button = Button(pg.Rect(50, 50, 120, 40), "Click Me!")
        self.label = Label(pg.Rect(50, 100, 120, 40), "This is text :)")
        self.edit_field = EditField(pg.Rect(200, 50, 220, 40), "Edit me...")
        self.text_field = TextField(pg.Rect(200, 100, 520, 440), "This is a long text :).\nIt supports multi-lines, copy-paste, selection, ...")

    def tick(self):
        if self.button.is_clicked:
            self.text_field.set_text(self.edit_field.text)
        if self.label.is_clicked:
            print('label clicked')


if __name__ == '__main__':
    viewer = MyViewer()
    viewer.run()

To get more finegrained control over the UI, see the implementation of the peng_ui.viewer.Viewer class.

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

peng_ui-0.3.5.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

peng_ui-0.3.5-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file peng_ui-0.3.5.tar.gz.

File metadata

  • Download URL: peng_ui-0.3.5.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for peng_ui-0.3.5.tar.gz
Algorithm Hash digest
SHA256 4a5de85ab451c1b152f6339c86e1f8912d8f3cacb05694bfc32f2fad63d4b33c
MD5 1ad9207b7ccc6435701ff1b07493f968
BLAKE2b-256 7a5cb23315c79f87d24afa096a5c2ceb369a084fe9fc8f9b326a67c7de0a3257

See more details on using hashes here.

File details

Details for the file peng_ui-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: peng_ui-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for peng_ui-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 458fa8d1ba4c0791012385a8f6b533674a226d4456b73836a02dfc7c85fb9201
MD5 c01acf63b38807821c4dcfabf7bda78d
BLAKE2b-256 c4a296d2c366dfb2ea3917a4fcc3f24551e880b61e31a7015f0f2670ae6e3d25

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