Python: module rox.Menu

rox.Menu | index

`The Menu widget provides an easy way to create menus that allow the user to
define keyboard shortcuts, and saves the shortcuts automatically. You only define
each Menu once, and attach it to windows as required.
Example:
from rox.Menu import Menu, set_save_name
set_save_name('Edit')
menu = Menu('main', [
('/File', '', '<Branch>'),
('/File/Save', 'save', ''),
('/File/Open Parent', 'up', ''),
('/File/Close', 'close', ''),
('/File/', '', '<Separator>'),
('/File/New', 'new', ''),
('/Edit', '', '<Branch>'),
('/Edit/Undo', 'undo', ''),
('/Edit/Redo', 'redo', ''),
('/Edit/', '', '<Separator>'),
('/Edit/Search...', 'search', ''),
('/Edit/Goto line...', 'goto', ''),
('/Edit/', '', '<Separator>'),
('/Edit/Process...', 'process', ''),
('/Options', 'show_options', ''),
('/Help', 'help', '', 'F1'),
])`

Classes
`` |  | Menu
class Menu
`` |
| Methods defined here: __init__(self, name, items) `names should be unique (eg, 'popup', 'main', etc). items is a list of menu items: [(name, callback_name, type, key), ...]. 'name' is the item's path. 'callback_name' is the NAME of a method to call. 'type' is as for g.ItemFactory. 'key' is only used if no bindings are in Choices.` attach(self, window, object) `Keypresses on this window will be treated as menu shortcuts for this object, calling 'object.<callback_name>' when used.` popup(self, caller, event) `Display the menu. Call 'caller.<callback_name>' when an item is chosen.`

Functions
`` |  | set_save_name(prog, leaf='menus') `Set the directory/leafname (see choices) used to save the menu keys. Call this before creating any menus.`