Skip to content

Instantly share code, notes, and snippets.

@dirn
Created July 30, 2013 02:19
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 dirn/6109670 to your computer and use it in GitHub Desktop.
Save dirn/6109670 to your computer and use it in GitHub Desktop.
from collections import deque
import curses
from random import randrange, shuffle
from time import sleep
def display(stdscr, state):
stdscr.addstr(0, 0, ' '.join(state))
stdscr.addstr(1, 0, ' ' * (len(state) // 2) + '\u2191')
if __name__ == '__main__':
stdscr = curses.initscr()
curses.start_color()
curses.noecho()
curses.cbreak()
wheel = deque(map(str, range(10)))
shuffle(wheel)
try:
for x in range(randrange(10, 20)):
display(stdscr, wheel)
stdscr.refresh()
sleep(1)
wheel.rotate(1)
finally:
curses.nocbreak()
curses.echo()
curses.endwin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment