Beispiel #1
0
    def _print_menu(self):
        self.parent._print_menu()

        for i in xrange(0, self.host.height - len(self.host.options)):
            ansi.clear_eol()
            ansi.write("\n")
        if self.text is not None:
            ansi.write("/" + "".join(self.text))
            ansi.show_cursor()
        ansi.clear_eol()
Beispiel #2
0
 def show(self):
     import keyboard
     self._print_menu()
     ansi.save_position()
     ansi.hide_cursor()
     try:
         for key in keyboard.keyboard_listener():
             stop = self._on_key(key)
             if stop:
                 return self.get_result()
             self._goto_top()
             self._print_menu()
     finally:
         self._clear_menu()
         ansi.show_cursor()
Beispiel #3
0
 def show(self):
     import keyboard
     ansi.hide_cursor()
     self._print_menu(rewind=False)
     try:
         for key in keyboard.keyboard_listener():
             if key == "enter":
                 self._clear_menu()
                 ansi.write(self.options[self.cursor])
                 return self.options[self.cursor]
             elif key == "esc":
                 self._clear_menu()
                 ansi.write("<esc>")
                 return None
             elif key == "left":
                 self.cursor = max(0, self.cursor - 1)
             elif key == "right":
                 self.cursor = min(len(self.options) - 1, self.cursor + 1)
             self._print_menu(rewind=True)
     finally:
         ansi.show_cursor()
         ansi.write("\n")