I've been trying to get this script to work as intended but have been having some issues in doing so. I'm trying to change the string displayed on screen depending on the variable pageCount, but have ran into 2 issues so far.
I would like the first string (page1) to be printed before the key stroke that getkey() is waiting for, but I can't seem to achieve this. I also cannot get the screen to refresh/clear properly when a new string is printed on screen.
What would the best method to fix these issues be?
from curses import wrapper
def main(stdscr):
# Clear screen
pageCount=0
#stdscr.addstr(str(pageCount))
stdscr.clear()
while True:
key=stdscr.getkey()
if key == "KEY_LEFT":
pageCount=pageCount-1
if key == "KEY_RIGHT":
pageCount=pageCount+1
if pageCount < 1:
pageCount=10
if pageCount > 10:
pageCount=1
if pageCount==1:
stdscr.addstr("page 1")
if pageCount==2:
stdscr.addstr("page 2")
if pageCount==3:
stdscr.addstr("page 3")
if pageCount==4:
stdscr.addstr("page 4")
if pageCount==5:
stdscr.addstr("page 5")
if pageCount==6:
stdscr.addstr("page 6")
if pageCount==7:
stdscr.addstr("page 7")
if pageCount==8:
stdscr.addstr("page 8")
if pageCount==9:
stdscr.addstr("page 9")
if pageCount==10:
stdscr.addstr("page 10")
stdscr.refresh()
wrapper(main)