A lightweight and intuitive Pygame GUI library
- 🔲 Button - Clickable buttons with hover effects
- 📝 InputBox - Text input fields
- 🏷️ Label - Simple text display
- 🎚️ Slider - Adjustable value control
- ☑️ Checkbox - Toggle options
- 📝 Dropdown - Selection from multiple options
import pygame
from gui import GUIManager, Button
pygame.init()
screen = pygame.display.set_mode((400, 200))
gui = GUIManager()
def on_click():
print("Button clicked!")
gui.add(Button((100, 70, 200, 50), "Click Me", on_click))
running = True
while running:
screen.fill((30, 30, 30))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
gui.handle_event(event)
gui.draw(screen)
pygame.display.flip()Button((x, y, width, height), "Button Text", callback_function)InputBox((x, y, width, height), "Initial Text")Slider((x, y, width, height), min_value, max_value, initial_value, callback_function)CheckBox((x, y, width, height), "Checkbox Text", initial_state, callback_function)Dropdown((x, y, width, height), ["Option1", "Option2", "Option3"], callback_function)Check out the examples folder for complete demonstrations of each component:
button.py- Button demonstrationtextinput.py- Input box usageSlider.py- Slider controlcheckbox- Checkbox implementationdropdown.py- Dropdown menuall.py- Complete showcase of all widgets
- Python 3.x
- Pygame
MIT License
Contributions, issues, and feature requests are welcome!
