예제 #1
0
 def test_init(self):
     selection_item_1 = SelectionItem("selection_item_1", 1, self.menu)
     selection_item_2 = SelectionItem(text="selection_item_2",
                                      index=2,
                                      menu=self.menu)
     self.assertEqual(selection_item_1.text, "selection_item_1")
     self.assertEqual(selection_item_2.text, "selection_item_2")
     self.assertEqual(selection_item_1.menu, self.menu)
     self.assertEqual(selection_item_2.menu, self.menu)
     self.assertTrue(selection_item_1.should_exit)
     self.assertTrue(selection_item_2.should_exit)
예제 #2
0
 def __init__(self,
              strings,
              title=None,
              subtitle=None,
              show_exit_option=True,
              formatter=None,
              prologue_text=None,
              epilogue_text=None):
     """
     :ivar list[str] strings: The list of strings this menu should be built from
     """
     super(SelectionMenu, self).__init__(title,
                                         subtitle,
                                         show_exit_option,
                                         formatter=formatter,
                                         prologue_text=prologue_text,
                                         epilogue_text=epilogue_text)
     for index, item in enumerate(strings):
         self.append_item(SelectionItem(item, index, self))
예제 #3
0
 def __init__(self,
              strings,
              title=None,
              subtitle=None,
              screen=None,
              formatter=None,
              prologue_text=None,
              epilogue_text=None,
              show_exit_option=True,
              exit_option_text='Exit'):
     super(SelectionMenu, self).__init__(title,
                                         subtitle,
                                         screen=screen,
                                         formatter=formatter,
                                         prologue_text=prologue_text,
                                         epilogue_text=epilogue_text,
                                         show_exit_option=show_exit_option,
                                         exit_option_text=exit_option_text)
     for index, item in enumerate(strings):
         self.append_item(SelectionItem(item, index, self))
예제 #4
0
 def append_string(self, string):
     self.append_item(SelectionItem(string))