Skip to main content

A button GUI module for Pygame.

Project description


**A Button UI Element for Pygame**

Pygbutton is a simple button UI that you can add to your Pygame programs.

You can download a few example programs here:

The code to implement it is fairly basic:

import pygbutton
buttonObj = pygbutton.PygButton((50, 50, 60, 30), 'Button Caption')
while True: # main game loop
for event in pygame.event.get(): # event handling loop
if 'click' in buttonObj.handleEvent(event):
pass # Do stuff in response to button click here.
buttonObj.draw(DISPLAYSURFACE) # where DISPLAYSURFACE was the Surface object returned from pygame.display.set_mode()

The full explanation of the code and how it was written can be found in the aboved linked blog post.

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 Pygbutton, version 0.9.0
Filename, size File type Python version Upload date Hashes
Filename, size (12.4 kB) File type Source Python version None Upload date Hashes View

Supported by

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