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.4.tar.gz
(14.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
peng_ui-0.3.4-py3-none-any.whl
(18.1 kB
view details)
File details
Details for the file peng_ui-0.3.4.tar.gz.
File metadata
- Download URL: peng_ui-0.3.4.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35a16aa2293670544860a6e5d7be8d8b5d28fae3e2e1f2dee95c898dda01933f
|
|
| MD5 |
171d34b00322285fccd99115555b0b0a
|
|
| BLAKE2b-256 |
4afc9e4d99d44b5e5ea35c80715b6d238f52f53cdb2158f48be95d984ce4a26e
|
File details
Details for the file peng_ui-0.3.4-py3-none-any.whl.
File metadata
- Download URL: peng_ui-0.3.4-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03a277376322197562dacb9661fe765906757c519caa0753a692f1d0ac3b89b1
|
|
| MD5 |
d703c468c065b51fe4889ec144f393c4
|
|
| BLAKE2b-256 |
2b1b7f307e421e44273c3f9999d917074d453549f647a49f85b6e2571a934e37
|