A simple Python menu-based GUI system on the terminal using curses.
Perfect for those times when you need a GUI, but don’t want the overhead
or learning curve of a full-fledged GUI framework. However, it’s also
flexible enough to do cool stuff like on-the-fly changing of menus and is extensible to
a large variety of uses.
It’s designed to be pretty simple to use. Here’s an example
# Import the necessary packagesfromcursesmenuimport*fromcursesmenu.itemsimport*# Create the menumenu=CursesMenu("Title","Subtitle")# Create some items# MenuItem is the base class for all items, it doesn't do anything when selectedmenu_item=MenuItem("Menu Item")# A FunctionItem runs a Python function when selectedfunction_item=FunctionItem("Call a Python function",input,["Enter an input"])# A CommandItem runs a console commandcommand_item=CommandItem("Run a console command","touch hello.txt")# A SelectionMenu constructs a menu from a list of stringsselection_menu=SelectionMenu(["item1","item2","item3"])# A SubmenuItem lets you add a menu (the selection_menu above, for example)# as a submenu of another menusubmenu_item=SubmenuItem("Submenu item",selection_menu,menu)# Once we're done creating them, we just add the items to the menumenu.append_item(menu_item)menu.append_item(function_item)menu.append_item(command_item)menu.append_item(submenu_item)# Finally, we call show to show the menu and allow the user to interactmenu.show()