I know some people are like: what the heck? How do you do that without inputs. Like how! Thats impossible!
Now, its really tough to achieve this, literally just do input() and done. But if you want this kind of inventory scrolling, its just on another level.
a whole 1500+ characters compared to a simple 7 line character input() function…
I would literally recommend you to never ever do this:
import curses
options = ["go in", "go out"]
selection = 0
def draw_menu(stdscr):
stdscr.clear()
stdscr.addstr(0, 0, "Options:")
for i, option in enumerate(options):
if i == selection:
stdscr.addstr(i+1, 0, "> " + option, curses.A_REVERSE)
else:
stdscr.addstr(i+1, 0, " " + option)
stdscr.refresh()
def main(stdscr):
global selection # explicitly declare the use of selection as a global variable
curses.curs_set(0)
stdscr.keypad(True)
while True:
draw_menu(stdscr)
key = stdscr.getch()
if key == curses.KEY_UP:
selection -= 1
if selection < 0:
selection = len(options) - 1
elif key == curses.KEY_DOWN:
selection += 1
if selection == len(options):
selection = 0
elif key in [10, 13]:
curses.curs_set(1)
stdscr.clear()
stdscr.addstr(0, 0, "Selected option: " + options[selection])
stdscr.refresh()
curses.napms(1000)
break
curses.curs_set(1)
curses.napms(1000)
curses.wrapper(main)
Here you go enjoy lolz.