simple widgets for pygame like button, checkbox, and textbox
Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
PygameUI
README.md
example.py

README.md

PygameUI

It has simple widgets like button, checkboxes, textboxes, and more. There also Page Flipping model. There are also some tools like gradient, pathfinder, and more. PygameUI is in it first stages. Meaning things will change and break.


Page Flipping examples.

Example 1. how to open simple PygameUI screen.

import PygameUI as UI

if __name__ == '__main__':
    # Tell screen to initialize pygame window
    UI.screen.handle.set_screen('Simple PygameUI Screen', (800,600))
    # Tell screen to start flipping.
    UI.screen.handle.loop(None)

Example 2. how to use PygameUI page.

import PygameUI as UI

# Making a page. 
class Page(UI.screen.Page):
    def blit(self, surface):
        surface.fill((200,0,0))

if __name__ == '__main__':
    UI.screen.handle.set_screen('PygameUI Page Example', (800,600))
    # storing a page
    UI.screen.handle.page['page'] = Page()
    # Tell screen to start flipping with page.
    UI.screen.handle.loop('page')

Update code to follow pep8 style guide http://www.python.org/dev/peps/pep-0008/

Did a clean up and simplified screen.py. Just trying to follow KISS (Keep It Simple Stupid).

If you like widget to handle them self. here an option.

class WidgetControlPage(object):
    def __init__(self, page):
        self.page = page

    def entrance(self):
        self.page.entrance()

    def on_exit(self):
        self.page.on_exit()

    def blit(self, surface):
        self.page.blit(surface)
        for key in self.widgets.iterkeys():
            self.page.widgets[key].blit(surface)

    def event(self, event):
        self.page.event(event)
        for key in self.widgets.iterkeys():
            self.page.widgets[key].event(event)

    def update(self, tick):
        self.page.update(tick)
        for key in self.widgets.iterkeys():
            self.page.widgets[key].update(tick)