Exemplo n.º 1
0
    def Clear(self, hints):
        ## Clear the printed options
        Display.ClearPreviousLine()
        Display.ClearPreviousLine()

        ## Clear hints
        if hints: self._ClearHints()
Exemplo n.º 2
0
    def Clear(self, hints):
        ## Clear hints
        if hints: self._ClearHints()

        ## Clear the previously displayed options
        Display.ClearPreviousLine()

        for i in range(0, len(self.opts)):
            Display.ClearPreviousLine()
Exemplo n.º 3
0
    def __DisplayMenu(self, numbered, hints):
        ## Declare the selected option index
        selected = 0

        ## Infinite loop broken by return
        while True:
            for ind, opt in enumerate(self.opts):
                if numbered:
                    op = "%i - %s" % (ind + 1, opt[0])
                else:
                    op = opt[0]

                if ind == selected:
                    print("\033[0;32m{}\033[0m".format(op), end="\n")
                else:
                    print(op, end="\n")

            # Forcing options to show (would be delayed until after keypress in Python 3)
            sys.stdout.flush()

            print("")

            ## Display Hints
            if hints: self._DisplayHints()

            ## Catch pressed key and option
            opt = None
            key_pressed = None
            while key_pressed == None:
                ## Get key preset input index from user
                key_pressed = self.keyPreset.Input()

                if key_pressed == 1 and selected < len(self.opts) - 1:
                    selected += 1
                elif key_pressed == 0 and selected > 0:
                    selected -= 1
                elif key_pressed == 2:
                    opt = self.opts[len(self.opts) - 1]
                elif key_pressed == 3:
                    opt = self.opts[selected]
                elif key_pressed == 4:
                    ## Clear the text
                    self.Clear(hints)

                    Display.ClearPreviousLine()

                    ## Call the last option
                    return self.opts[len(self.opts) - 1]

            ## Clear the text
            self.Clear(hints)

            ## Return if anything was selected
            if opt:
                Display.ClearPreviousLine()
                return opt
Exemplo n.º 4
0
 def _ClearHints(self):
     ## Clear previous hints
     Display.ClearPreviousLine()