I'm quite new to curses, so I'm trying out some different things in python.
I've initialized the window and set scrollok for the window object. I can add strings, and the scrolling works so that addstr() doesn't have any errors at the end of the window.
What I'd like to have is the ability to scroll back in the program output in my terminal program (tmux or KDE Konsole, in this case) after the program has finished.
In my code, I can at least see the output if I skip the endwin() call, but then the terminal needs a reset call to get back to operational.
Also, even while the program is running, after the curses window has scrolled down, I can't scroll back in Konsole to see the initial output.
#!/usr/bin/env python2
import curses
import time
win = curses.initscr()
win.scrollok(True)
(h,w)=win.getmaxyx()
h = h + 10
while h > 0:
win.addstr("[h=%d] This is a sample string. After 1 second, it will be lost\n" % h)
h = h - 1
win.refresh()
time.sleep(0.05)
time.sleep(1.0)
curses.endwin()