Skip to content

Instantly share code, notes, and snippets.

@ashwinvis
Last active February 2, 2018 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashwinvis/fec85ef064eb3ead3f58d2c0d2c13371 to your computer and use it in GitHub Desktop.
Save ashwinvis/fec85ef064eb3ead3f58d2c0d2c13371 to your computer and use it in GitHub Desktop.
import curses
from random import randint
# Print random text in a 10x10 grid
stdscr = curses.initscr()
for rows in range(10):
line = ''.join([chr(randint(41, 90)) for i in range(10)])
stdscr.addstr(line + '\n')
icol = 3 - 1
irow = 6 - 1
# Read
ch = stdscr.instr(irow, icol, 1).decode(encoding="utf-8")
# Show result
stdscr.move(irow, icol + 10)
stdscr.addstr('Character at column 3, row 6 = ' + ch + '\n')
stdscr.getch()
curses.endwin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment