File: urwid_attr.py

package info (click to toggle)
urwid 3.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,232 kB
  • sloc: python: 29,010; javascript: 382; sh: 34; makefile: 22
file content (22 lines) | stat: -rw-r--r-- 504 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from __future__ import annotations

import urwid


def exit_on_q(key: str) -> None:
    if key in {"q", "Q"}:
        raise urwid.ExitMainLoop()


palette = [
    ("banner", "black", "light gray"),
    ("streak", "black", "dark red"),
    ("bg", "black", "dark blue"),
]

txt = urwid.Text(("banner", " Hello World "), align="center")
map1 = urwid.AttrMap(txt, "streak")
fill = urwid.Filler(map1)
map2 = urwid.AttrMap(fill, "bg")
loop = urwid.MainLoop(map2, palette, unhandled_input=exit_on_q)
loop.run()