This Package adds UI Elements like Buttons and Textboxes to PyGame.
Project description
Changelog:
- Fixed Bugs
- Added pgt.square() function (for more information look at the Elements section)
pygametext
This Package adds UI Elements to PyGame.
Install
pip install pygametext
Import
import pygametext
Initiate pygametext
pgt = pygametext.PGT(screen)
Elements
pgt.button(x,y,width,height,buttonColor,"Text",textColor,onClickFunction,onClickArguments,layer)
-> Returns True
pgt.switch(x,y,width,height,buttonColor,"Text",textColor,activeFunction,activeArguments,layer)
-> Returns True
pgt.checkbox(x,y,scale,color,activeFunction,activeArguments,layer)
-> Returns True
pgt.text(x,y,"Text",textColor,textSize,layer)
-> Returns True
pgt.square(x,y,width,height,color,layer)
-> Returns True
pgt.textbox(x,y,width,height,textColor,layer)
-> Returns True
Process inputs and events
This function needs to be called if you want that the elements on specified layer to be interactive.
pgt.update(layer)
Draw elements to screen
This function needs to be called if you want that the elements on specified layer to be drawn.
pgt.draw(layer)
Utitilty functions
pgt.getLayer(layer)
-> Returns list of PGT Objects on specified Layer
pgt.clear(id,layer)
-> Returns True or False
pgt.rebuild(layer)
-> Returns True
import pygame
import pygametext
running = True
pygame.init()
screen = pygame.display.set_mode((640, 360))
clock = pygame.time.Clock()
pgt = pygametext.PGT(screen) # Define pygametext object.
pgt.button(10,10,100,50,(255,0,0),"Hello!",(0,0,0),print,"Hello World!",0) # Add pgt Button
pgt.button(120,10,100,50,(255,255,0),"Bye bye",(0,0,0),print,"Goodbye World!",0) # Add pgt Button
pgt.text(10,70,"Simple pygametext example.",(0,120,0),20,0) # Add pgt Text
def update(): # Update & Eventd
events = pygame.event.get()
pgt.update(events, 0) # Update all pgt elements from layer 0. Takes events arg to process some elements.
for event in events:
if event.type == pygame.QUIT:
running = False
pygame.quit()
quit()
def draw():
screen.fill((255,255,255)) # Clear screen
pgt.draw() # Draw all pgt elements from layer 0
pygame.display.flip()
while running:
update()
draw()
clock.tick(60)
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
Built Distribution
File details
Details for the file pygametext-0.1.0.4.tar.gz
.
File metadata
- Download URL: pygametext-0.1.0.4.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78b86d104d3b3c3f5061274562e9f9e1c42bac62dc00f618159605c48342e390 |
|
MD5 | 475e39639a67cd33a96adefdbab103a4 |
|
BLAKE2b-256 | 193282a5bd3060714ea8c3228700c0fbb136c58cc9dae4b636e82030e7043f06 |
File details
Details for the file pygametext-0.1.0.4-py3-none-any.whl
.
File metadata
- Download URL: pygametext-0.1.0.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb4a44cb5ac42f84f57c1701229380a73713287dea7fb91da14a9976973b16b0 |
|
MD5 | 52b46b6ec7712f25ae526ab7c4fb98b3 |
|
BLAKE2b-256 | 800ef57fcc275423a123c03199c84f1b81d76210b10b5cc834f8f020cad4af49 |