Пример #1
0
def display_pages(log):
    global splash
    page = 0
    fr = 0
    to = 20
    page_max = len(log) // 20
    while (1):
        clear_screen()
        print(log[fr:to])
        print(line_offset + "Page {} out of {}".format(page + 1, page_max))
        keyreader = kr.KeyReader()
        inp, outp, err = select.select([sys.stdin], [], [])
        entry = keyreader.getch()
        if (entry == left):
            if (page == 0):
                pass
            else:
                page -= 1
                fr = 0 + page * 20
                to = 20 + page * 20
        elif (entry == right):
            if (page + 1 == page_max):
                if (len(log) % 20 != 0):
                    fr = page * 20
                    to = page * 20 + len(log) % 20
                    page += 1
            elif page + 1 > page_max:
                pass
            else:
                page += 1
                fr = 0 + page * 20
                to = 20 + page * 20
        elif (entry == quit):
            return
        del keyreader
Пример #2
0
def launch_menu(options, header=''):
    global splash
    line_select = 0
    line_max = len(options) - 1
    if line_max < 1:
        return 0
    while (1):
        clear_screen()
        if (header != ''):
            print(header + '\n')
        for i in range(0, line_max + 1):
            if (i == line_select):
                print(line_offset + "> " + options[i])
            else:

                print(line_offset + "  " + options[i])

        keyreader = kr.KeyReader()
        inp, outp, err = select.select([sys.stdin], [], [])
        entry = keyreader.getch()
        del keyreader
        if (entry == down):
            if (line_select < line_max):
                line_select = line_select + 1
            else:
                line_select = 0
        elif (entry == up):
            if (line_select > 0):
                line_select = line_select - 1
            else:
                line_select = line_max
        elif (entry == chr(10)):
            return line_select
Пример #3
0
def display_log_pages(options, header=''):
    global splash
    page = 0
    fr = 0
    to = 19
    page_max = len(options) // 20
    if not (len(options) % 20 == 0):
        page_max += 1
    line_select = 0
    line_max = len(options) - 1
    if line_max < 1:
        return 0
    while (1):
        clear_screen()
        if (header != ''):
            print(header + '\n')


#        print(line_select)
        for i in range(fr, to + 1):
            if (i == line_select):
                print(line_offset + "> " + options[i])
            else:
                print(line_offset + "  " + options[i])
        print(line_offset + "Page {} out of {}".format(page + 1, page_max))
        keyreader = kr.KeyReader()
        inp, outp, err = select.select([sys.stdin], [], [])
        entry = keyreader.getch()
        del keyreader
        if (entry == down):
            if (line_select < to):
                line_select = line_select + 1
            else:
                line_select = fr
        elif (entry == up):
            if (line_select > fr):
                line_select = line_select - 1
            else:
                line_select = to
        elif (entry == chr(10)):
            return line_select
        elif (entry == left):
            if (page == 0):
                pass
            else:
                page -= 1
                fr = 0 + page * 20
                to = 20 + page * 20
                line_select = line_select - 20
        elif (entry == right):
            if (page < page_max - 1):
                page += 1
                fr += 20
                to += 20
                line_select += 20
                if (line_select > len(options)):
                    line_select = fr
                if (to > len(options)):
                    to = len(options) - 1
            else:
                pass