Skip to main content

Simple Pygame Menu - 1.0

A low-fuss, infinitely nested popup menu for pygame. It don't get no simpler den dis.


Gummbum
(gummbum)
A low-fuss, infinitely nested popup menu for pygame. It don't get no simpler den dis.

Inspired by SimpleMenu for pyglet.

I couldn't find one of these for pygame, so I wrote one and decided to make it reusable. Hope you enjoy.

Gumm


menu_data = (
    'Main',
    'Item 0',
    'Item 1',
    (
        'Things',
        'Item 0',
        'Item 1',
        'Item 2',
        (
            'More Things',
            'Item 0',
            'Item 1',
        ),
    ),
    'Quit',
)
PopupMenu(menu_data)
for e in pygame.event.get():
    if e.type == USEREVENT and e.code == 'MENU':
        print 'menu event: %s.%d: %s' % (e.name,e.item_id,e.text)
        if (e.name,e.text) == ('Main','Quit'):
            quit()

Changes

Links

Home Page
http://code.google.com/p/simple-pygame-menu/
Source
http://simple-pygame-menu.googlecode.com/svn/trunk/

Releases

Simple Pygame Menu 1.0 — 4 Dec, 2010

Simple Pygame Menu 1.2 — 7 Dec, 2010

Pygame.org account Comments

  • josmiley 2011-09-22 10:22

    good,
    i'm actually trying do to the same thing ...

  • Raj 2012-03-25 07:07

    I ran the code, however it gave me an error saying that 'PopupMenu not defined'. What's the fix? Anybody?