Python Forum
I want to be able to scroll up in curses to see previous text. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: I want to be able to scroll up in curses to see previous text. (/thread-40442.html)



I want to be able to scroll up in curses to see previous text. - Caiden - Jul-27-2023

I have some code that just prints the same thing over and over and its numbered but when I try scrolling up it doesn't work, But I wanna be able to scroll up using mouse scroll wheel and have like the actual scrollbar present and using keys such as pg up ect... like in a normal terminal. Now I do know curses just overlays on-top of the terminal that's why I'm wondering if there is a way to do all of this?

import curses, time
def print_hello(chat_win):
    num = 0
    while True:
        chat_win.addstr(f"Test Bot. {num} \n")
        chat_win.refresh()
        time.sleep(0.5)
        num += 1
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(True)
curses.curs_set(0)
chat_win = curses.newwin(curses.LINES, curses.COLS, 0, 0)
chat_win.scrollok(True)
print_hello(chat_win)
Currently it just prints and whatever goes off screen at the top(previous old text) gets deleted entirety.
Thank you in advance.


RE: I want to be able to scroll up in curses to see previous text. - deanhystad - Jul-28-2023

So you want your program that runs in a terminal window to act like it is running in a terminal window. Why are you using curses? What am I missing?