Exemple #1
0
    def setUp(self):
        super(TestSampleMenu, self).setUp()

        self.menu = CursesMenu("self.menu", "TestSampleMenu")
        self.item1 = MenuItem("self.item1", self.menu)
        self.item2 = MenuItem("self.item2", self.menu)
        self.menu.append_item(self.item1)
        self.menu.append_item(self.item2)
        self.menu.start()
        self.menu.wait_for_start(timeout=10)
 def test_init(self):
     menu_item_1 = MenuItem("menu_item_1", self.menu)
     menu_item_2 = MenuItem("menu_item_2", self.menu, True)
     menu_item_3 = MenuItem(text="menu_item_1", menu=self.menu, should_exit=False)
     self.assertEqual(menu_item_1.text, "menu_item_1")
     self.assertEqual(menu_item_2.text, "menu_item_2")
     self.assertEqual(menu_item_3.text, "menu_item_1")
     self.assertEqual(menu_item_1.menu, self.menu)
     self.assertEqual(menu_item_2.menu, self.menu)
     self.assertEqual(menu_item_3.menu, self.menu)
     self.assertFalse(menu_item_1.should_exit)
     self.assertTrue(menu_item_2.should_exit)
     self.assertFalse(menu_item_3.should_exit)
Exemple #3
0
def step_impl(context):
    context.menu = CursesMenu("Test Menu", "Subtitle")
    context.menu_item = MenuItem("NORMAL", "Menu Item")
    context.menu.append_item(context.menu_item)
    context.function_item = FunctionItem("NORMAL", "Call a Python function",
                                         input, ["Enter an input"])
    context.menu.append_item(context.function_item)
    pass
Exemple #4
0
def step_impl(context):
    context.menu = CursesMenu("Test Menu", "Subtitle")
    context.menu_item = MenuItem("NORMAL", "Menu Item")
    context.menu.append_item(context.menu_item)
    context.function_item = FunctionItem("NORMAL", "Call a Python function",
                                         input, ["Enter an input"])
    context.menu.append_item(context.function_item)
    context.command_item = CommandItem("NORMAL", "Run a console command",
                                       "ipconfig /all")
    context.menu.append_item(context.command_item)
    context.selection_menu = SelectionMenu(["item1", "item2", "item3"])
    context.selection_submenu_item = SubmenuItem("NORMAL", "Submenu item",
                                                 context.selection_menu)
    context.menu.append_item(context.selection_submenu_item)
    pass
Exemple #5
0
def step_impl(context):
    context.menu = CursesMenu("Test Menu", "Subtitle")
    context.menu_item = MenuItem("NORMAL", "Menu Item")
    context.menu.append_item(context.menu_item)
    pass
Exemple #6
0
def step_impl(context):
    context.menu_item = MenuItem("NORMAL", "Menu Item")
    context.menu.append_item(context.menu_item)
    pass
Exemple #7
0
# Example copied from pypi.org/project/curses-menu/
# Import the necessary packages
from cursesmenu import CursesMenu, SelectionMenu
from cursesmenu.items import MenuItem, FunctionItem, CommandItem, SubmenuItem

# Create the menu
menu = CursesMenu("Title", "Subtitle")

# Create some items

# MenuItem is the base class for all items, it doesn't do anything when selected
menu_item = MenuItem("Menu Item")

# A FunctionItem runs a Python function when selected
function_item = FunctionItem("Call a Python function", input,
                             ["Enter an input"])

# A CommandItem runs a console command
command_item = CommandItem("Run a console command", "touch hello.txt")

# A SelectionMenu constructs a menu from a list of strings
selection_menu = SelectionMenu(["item1", "item2", "item3"])

# A SubmenuItem lets you add a menu (the selection_menu above, for example)
# as a submenu of another menu
submenu_item = SubmenuItem("Submenu item", selection_menu, menu)

# Once we're done creating them, we just add the items to the menu
menu.append_item(menu_item)
menu.append_item(function_item)
menu.append_item(command_item)
 def test_show(self):
     menu_item = MenuItem("menu_item", self.menu)
     self.assertEqual(menu_item.show(0), "1 - menu_item")
Exemple #9
0
def step_impl(context):
    context.menu_item3 = MenuItem("BLUE", "Menu Item")
Exemple #10
0
def step_impl(context):
    context.menu_item4 = MenuItem("MAGENTA", "Menu Item")
Exemple #11
0
def step_impl(context):
    context.menu_item2 = MenuItem("YELLOW", "Menu Item")
Exemple #12
0
def step_impl(context):
    context.menu_item1 = MenuItem("GREEN", "Menu Item")
Exemple #13
0
def step_impl(context):
    context.menu_item = MenuItem("RED", "Menu Item")
Exemple #14
0
def step_impl(context):
    context.menu_item6 = MenuItem("WHITE", "Menu Item")
Exemple #15
0
def step_impl(context):
    context.menu_item5 = MenuItem("CYAN", "Menu Item")