Search code examples
python-3.xlistcursespython-curses

not able to append in a list in curses module?


I want to take a user input with python curses module but every time it is not adding any element in the list can any one please help mehere is the output

my code :-

import curses
from curses import wrapper
from curses.textpad import Textbox, rectangle

tempo_list = []


def main(stdscr, text="hello"):
    final_text = text + " (hit Ctrl-G to send)"
    for i in range(5):
        stdscr.addstr(0, 0, final_text)
        win = curses.newwin(1, 21, 2, 1)
        box = Textbox(win)
        rectangle(stdscr, 1, 0, 3, 23)
        stdscr.refresh()
        box.edit()
        val = box.gather().replace("\n", "")
        tempo_list.append(val)


print(tempo_list)

wrapper(main)

Solution

  • You call wrapper(main) after you print the (empty) list. Change the order of the statements.