Advertisement
Guest User

Untitled

a guest
May 6th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import curses # probably won't run on MS Windows
  2. import time
  3. import string
  4. import random
  5.  
  6. nlet = len (string.letters) # it's 52 i swear
  7. fieldx = 80
  8. fieldy = 23 # will crash if the terminal window is resized
  9. sleeptime = 0.04
  10. charrep = 11
  11.  
  12. def randomch ():
  13. c = string.letters [random.randint(0, nlet - 1)]
  14. x = random.randint (0, fieldx - 1)
  15. y = random.randint (0, fieldy - 1)
  16. screen.addch (y, x, c)
  17.  
  18. def decurse ():
  19. curses.echo ()
  20. curses.endwin ()
  21.  
  22. # --- BEGIN ---
  23.  
  24. screen = curses.initscr ()
  25. curses.noecho ()
  26. curses.curs_set (0)
  27.  
  28. try:
  29. while True:
  30. for j in range (1, charrep):
  31. randomch ()
  32. screen.refresh ()
  33. time.sleep (sleeptime)
  34. except KeyboardInterrupt:
  35. pass
  36. finally:
  37. decurse ()
  38. print "^C"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement