Right now, after my Python program that uses curses
exits, I'm left with a blank screen. Anything that I'd done prior to running my program is no longer visible.
How can I make it so that after my curses program exits, the prior contents is visible, IE, the way that less
, man
, and vim
do on *nix.
Extra details: I'm using the Windows console, so *nix terminal commands won't work. For anyone wondering how I managed to get curses
working on Windows, see my answer over here .
My question is exactly the same as this one , except mine is specific to Python (not C) and Windows (not *nix).
PDCurses attempts to save the screen contents when it starts, and to restore it it you have set the PDC_RESTORE_SCREEN
environment variable (for Windows, of course).
By attempts , I mean that this may fail. Windows(using the [ReadConsoleOutput][1]
function) has a 64KB buffer used for this purpose, and large screensizes (especially counting the scrollback) may be too large. If it cannot save the whole buffer, it tries to save/restore only the part that you see (the "window"). Even that could be too large, of course.
In a quick check of ncurses on the other hand, I do not see this problem (so the problem lies in PDCurses).
From more reading (eg, this question ), I see that you are likely using UniCurses for Python , which would be more interesting if it were not for the fact that its author chose to license it in a way that precludes its inclusion in any python, ncurses (or PDCurses) release.
curses.endwin()
should do the trick.
Here's the documentation explaining it.
Also, here's where I've personally used this function .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.