File: box.py

package info (click to toggle)
python-asciimatics 1.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,488 kB
  • sloc: python: 15,713; sh: 8; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 1,040 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
"""
This module implements an ASCII box renderer.
"""

from asciimatics.constants import SINGLE_LINE
from asciimatics.renderers.base import StaticRenderer
from asciimatics.utilities import BoxTool


class Box(StaticRenderer):
    """
    Renders a simple box using ASCII characters.  This does not render in
    extended box drawing characters as that requires non-ASCII characters in
    Windows and direct access to curses in Linux.
    """

    def __init__(self, width, height, uni=False, style=SINGLE_LINE):
        """
        :param width: width of box
        :param height: height of box
        :param uni: True to use UNICODE character set, defaults to False
        :param style: desired line style, based on line style definitions in
            :mod:`~asciimatics.constants`: `ASCII_LINE`, `SINGLE_LINE`,
            `DOUBLE_LINE`. `uni` parameter takes precedence and the style will be
            ignored if `uni==False`
        """
        super().__init__()
        self._images = [BoxTool(uni, style).box(width, height)]