Trying to create a simple function that displays one line from a text file at a time when enter or page down key is pressed. I don't want the lines to clear each time. In other words, I need to pause the program until next key press. As it is it only displays the first line. I tried a while True: to no avail. Thanks for you help!
# Handle key presses
def handle_input(key):
with open('mobydick_ch1.txt') as f:
lines = f.readlines()
line_counter = 0
if key == 'enter' or key == 'page down':
text_box.base_widget.set_text(lines[line_counter])
line_counter += 1
main_loop.draw_screen()
elif key == 'Q' or key == 'q':
raise urwid.ExitMainLoop()