def test_menu_2(test): setinput("1") result = show_menu(test.entries, returns="desc") test.assertEqual("foo", result)
def test_menu_2(self): setinput("1") result = show_menu(self.entries, returns="desc") self.assertEqual("foo", result)
def test_menu_1(test): setinput("1") result = show_menu(test.entries) test.assertEqual("1", result)
def test_menu_1(self): setinput("1") result = show_menu(self.entries) self.assertEqual("1", result)
from qprompt import MenuEntry, show_menu, ask_yesno def foo(): print("foo") def bar(a): print("bar %r" % (a)) val = {'a': 42} entries = [MenuEntry("1", "Item A", foo, None, None)] entries.append(MenuEntry("2", "Item B", bar, None, val)) entries.append(MenuEntry("q", "Quit", None, None, None)) compact = ask_yesno("Use compact menu?") while "q" != show_menu(entries, compact=compact): pass
from qprompt import MenuEntry, show_menu, ask_yesno def foo(): print("foo") def bar(a): print("bar %r" % (a)) val = {'a':42} entries = [] entries.append(MenuEntry("1", "Item A", foo, None, None)) entries.append(MenuEntry("2", "Item B", bar, None, val)) entries.append(MenuEntry("q", "Quit", None, None, None)) compact = ask_yesno("Use compact menu?") while "q" != show_menu(entries, compact=compact): pass