File: bg_colours.py

package info (click to toggle)
python-asciimatics 1.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,488 kB
  • sloc: python: 15,713; sh: 8; makefile: 2
file content (45 lines) | stat: -rwxr-xr-x 1,453 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3

from asciimatics.effects import Wipe, Print
from asciimatics.renderers import FigletText, SpeechBubble
from asciimatics.scene import Scene
from asciimatics.screen import Screen
from asciimatics.exceptions import ResizeScreenError
import sys


def demo(screen):
    scenes = []

    for bg, name in [
            (Screen.COLOUR_DEFAULT, "DEFAULT"),
            (Screen.COLOUR_RED, "RED"),
            (Screen.COLOUR_YELLOW, "YELLOW"),
            (Screen.COLOUR_GREEN, "GREEN"),
            (Screen.COLOUR_CYAN, "CYAN"),
            (Screen.COLOUR_BLUE, "BLUE"),
            (Screen.COLOUR_MAGENTA, "MAGENTA"),
            (Screen.COLOUR_WHITE, "WHITE")]:
        effects = [
            Wipe(screen, bg=bg, stop_frame=screen.height * 2 + 30),
            Print(screen, FigletText(name, "epic"), screen.height // 2 - 4,
                  colour=bg if bg == Screen.COLOUR_DEFAULT else 7 - bg,
                  bg=bg,
                  start_frame=screen.height * 2),
            Print(screen,
                  SpeechBubble("Testing background colours - press X to exit"),
                  screen.height-5,
                  speed=1, transparent=False)
        ]
        scenes.append(Scene(effects, 0, clear=False))

    screen.play(scenes, stop_on_resize=True)


if __name__ == "__main__":
    while True:
        try:
            Screen.wrapper(demo)
            sys.exit(0)
        except ResizeScreenError:
            pass