File: simple.py

package info (click to toggle)
python-curtsies 0.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: python: 4,021; sh: 6; makefile: 5
file content (23 lines) | stat: -rw-r--r-- 819 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import random

from curtsies import FullscreenWindow, Input, FSArray

def main():
    """Returns user input placed randomly on the screen"""
    with FullscreenWindow() as window:
        print('Press escape to exit')
        with Input() as input_generator:
            a = FSArray(window.height, window.width)
            for c in input_generator:
                if c == '<ESC>':
                    break
                elif c == '<SPACE>':
                    a = FSArray(window.height, window.width)
                else:
                    row = random.choice(range(window.height))
                    column = random.choice(range(window.width-len(repr(c))))
                    a[row, column:column+len(repr(c))] = [repr(c)]
                window.render_to_terminal(a)

if __name__ == '__main__':
    main()