SHARE
TWEET

Untitled

a guest Apr 20th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. import asyncio
  3. import curses
  4.  
  5. async def blink(canvas, row, column, symbol='*'):
  6.     while True:
  7.         canvas.addstr(row, column, symbol, curses.A_DIM)
  8.         for _ in range(20):
  9.             await asyncio.sleep(0)
  10.  
  11.         canvas.addstr(row, column, symbol)
  12.         for _ in range(3):
  13.             await asyncio.sleep(0)
  14.  
  15.         canvas.addstr(row, column, symbol, curses.A_BOLD)
  16.         for _ in range(5):
  17.             await asyncio.sleep(0)
  18.  
  19.         canvas.addstr(row, column, symbol)
  20.         for _ in range(3):
  21.             await asyncio.sleep(0)
  22.  
  23. def draw(canvas):
  24.     canvas.border()
  25.     curses.curs_set(False)
  26.     canvas.refresh()
  27.     coroutine = blink(canvas, 5, 20)
  28.     while True:
  29.         try:
  30.             coroutine.send(None)
  31.             canvas.refresh()
  32.             time.sleep(0.1)
  33.         except StopIteration:
  34.             break
  35.  
  36. # def blinking_star(canvas, row, column, symbol='*'):    
  37. #     while True:
  38. #         canvas.addstr(row, column, symbol, curses.A_DIM)
  39. #         canvas.refresh()
  40. #         time.sleep(2)
  41.        
  42. #         canvas.addstr(row, column, symbol)
  43. #         canvas.refresh()
  44. #         time.sleep(0.3)
  45.        
  46. #         canvas.addstr(row, column, symbol, curses.A_BOLD)
  47. #         canvas.refresh()
  48. #         time.sleep(0.5)
  49.        
  50. #         canvas.addstr(row, column, symbol)
  51. #         canvas.refresh()
  52. #         time.sleep(0.3)
  53. # print(type(blink), dir(blink))
  54.  
  55. if __name__ == '__main__':
  56.     curses.update_lines_cols()
  57.     curses.wrapper(draw)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top