Open mobluse opened 5 months ago
I discovered my error: you have to use getch()
or some other delay mechanism, because curses prints to another screen and then switches back.
This works with both python
and snek
:
import curses
stdscr=curses.initscr()
stdscr.erase()
stdscr.addstr(5, 16, "Hello")
stdscr.move(9, 0)
stdscr.refresh()
stdscr.getch()
curses.endwin()
A minimal version for snek
:
curses.initscr()
stdscr.erase()
stdscr.addstr(5, 16, "Hello")
stdscr.move(9, 0)
stdscr.refresh()
stdscr.getch()
curses.endwin()
It might be useful to note this in the documentation. It's also useful that snek
can use some stdscr
methods without initscr()
.
I wrote a small test program in
snek
version 1.9 in most updated Debian GNU/Linux 12 (bookworm) aarch64 installed usingapt
on Raspberry Pi 4 B and I use LXTerminal 0.4.0, but it doesn't output when I usecurses.initscr()
, but works when I don't use it. It moves the cursor, buterase()
andaddstr()
doesn't affect the screen.This works:
I intended to write a small arcade game and then I probably need initscr() in order to read key presses without blocking, but now I'm stuck at not being able to output. Raspberry Pi with this OS and terminal emulator is a very common system.