File: keyboard_animation.py

package info (click to toggle)
python-blessed 1.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,812 kB
  • sloc: python: 14,645; makefile: 13; sh: 7
file content (16 lines) | stat: -rwxr-xr-x 419 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env python3
from blessed import Terminal

term = Terminal()
print("Cross animation, press any key to stop: ", end="", flush=True)
with term.cbreak(), term.hidden_cursor():
    cross = '|'

    while True:
        key = term.inkey(timeout=0.1)
        if key:
            print(f'STOP by {key!r}')
            break

        cross = {'|': '-', '-': '|'}[cross]
        print(f'{cross}\b', end='', flush=True)