PyMenu
The new library for making beautiful menus on numworks with dynamic accent colors. Thanks to cent20’s library, menu.py, for inspiring me for this library.
To give a little aspect, here is a demo script showing the options menu of my game snake_lite.
How to use
This is simple, you just need to create an instance of Menu class and set menu title, menu confirm label, and options, like this :
menu = Menu(
"My Title", # Replace by your menu title (e.g. "Game Options")
"Close menu", # Replace by your menu confirm label (e.g. "Start Game")
[ # And here is the options of menu.
#Must be formatted like this: ["<option label>", "<default value>", <values...>],
["My option", 0, "value 1", 2, [0,1]],
])
Note: The default option value must be an index of the list of values, not the value itself.
And after, just open the menu like this:
menu.open()
This will automatically clear the screen, format and display options, add a scrollbar if list exceed 6 options per page, handle keys to move through the menu, clear again the screen at end and return the result of selected options.
You can open the menu as many times you want by recalling the function, the last selected option will be automatically focused.