This page is out of date

You've reached a page on the Ren'Py wiki. Due to massive spam, the wiki hasn't been updated in over 5 years, and much of the information here is very out of date. We've kept it because some of it is of historic interest, but all the information relevant to modern versions of Ren'Py has been moved elsewhere.

Some places to look are:

Please do not create new links to this page.


Simple Pie Menus

I've been using this for testing purposes and it meets my needs. It may be a useful recipe to start from for anyone doing a similar task. This is written to follow the conventions of my project's "real" engine (KeyLimePie), so you may want to tweak it to suit your needs. My project expects to present options along the 8 cardinal directions ("n", "s", "nw", ...) and one "center" direction, for a simple 3x3 grid of choices. The code below replaces the built-in menu with a 3x3 grid menu. It expects menu choices to be prefixed by the direction in lowercase and a colon (ex: "se: Some Choice"). It expects all choices have a direction prefix, and it "stacks" direction choices so the direction always shows just the first applicable option in the list of choices.

The menu styling is fairly basic and not always great, but as I said I mostly use this just for testing. I'm also not sure the checkpoint code is correct (for save/load) as I haven't actually needed it.

I placed this code directly in the top init block of script.rpy, but it should work just fine in its own file (may need an "early" keyword, though).

   python:
       ## KeyLimePie Menu Powers Activate! ##
       style.create('keylimepie_menu_choice', 'default', 'KeyLimePie menu choice')
       style.create('keylimepie_menu_choice_button', 'default', 'KeyLimePie menu button')
       
       style.keylimepie_menu_choice.layout = "subtitle"
       style.keylimepie_menu_choice.xmaximum = 0.3
       style.keylimepie_menu_choice.size_group = None
       style.keylimepie_menu_choice_button.xmaximum = 0.3
       style.keylimepie_menu_choice_button.size_group = None
       
       # NOTE: It would be nice to intercept this at the renpy.export
       #  level instead, because we want the "disabled" items as well
       def keylimepie_menu(items):
           renpy.choice_for_skipping()
           
           # Roll forward
           roll_forward = renpy.roll_forward_info()
           
           choices = {}
           for label, value in items:
               pieces = label.split(':', 1)
               dir, label = pieces[0], pieces[1].strip()
               if dir not in choices:
                   choices[dir] = (label, value)
           
           renpy.ui.window(style=style.menu_window)
           renpy.ui.grid(3, 3)
           for dir in ('nw', 'n', 'ne', 'w', 'center', 'e', 'sw', 's', 'se'):
               if dir in choices:
                   renpy.ui.textbutton(choices[dir][0],
                       # style=style.menu_choice_button,
                       text_style=style.keylimepie_menu_choice,
                       clicked=renpy.ui.returns(choices[dir][1]),
                       focus=None,
                       default=None,
                   )
               else:
                   renpy.ui.text('') # TODO: Disabled choices?
           renpy.ui.close()
           renpy.shown_window()
           rv = renpy.ui.interact(mouse='menu', type='menu', roll_forward=roll_forward)
           renpy.checkpoint(rv)
           return rv
       menu = keylimepie_menu