Skip to main content

Create boxes in the terminal.

Project description

textpanel

Create boxes in the terminal.

Python port of boxen

Install

pip install textpanel

Usage

from textpanel import panel

print(panel("Hello World!",padding=1))
#╭──────────────╮
#│              │
#│ Hello World! │
#│              │
#╰──────────────╯

print(panel("Hello World!", padding=1, title='title'))
#╭───── title ──────╮
#│                  │
#│   Hello World!   │
#│                  │
#╰──────────────────╯

API

panel(text, style?, padding?, margin?, width?, expand?, border_color?, text_alignment?, text_color?, border?, title?, title_alignment?)

text

Required
Type: string
Text inside the box

border_style

Type: string | dict
Default: single
Values:

  • 'single'
┌───┐
│foo│
└───┘
  • 'double'
╔═══╗
║foo║
╚═══╝
  • 'round'
╭───╮
│foo│
╰───╯
  • 'bold'
┏━━━┓
┃foo┃
┗━━━┛
  • 'single-double'
╓───╖
║foo║
╙───╜
  • 'double-single'
╒═══╕
│foo│
╘═══╛
  • 'classic'
+---+
|foo|
+---+
  • 'arrow'
↘↓↓↓↙
→foo←
↗↑↑↑↖

Box border style

Can be custom defined with a dict:

{
    "topLeft": "┌",
    "topRight": "┐",
    "bottomRight": "┘",
    "bottomLeft": "└",
    "left": "│",
    "right": "│",
    "top": "─",
    "bottom": "─"
}

title

Type: str
Display a title at the top of the box.

title_alignment

Type: str
Default: left
Values: left center right
Align the title in the top bar.

  • 'left'
┌ title ────────┐
│foo bar foo bar│
└───────────────┘
  • 'center'
┌──── title ────┐
│foo bar foo bar│
└───────────────┘
  • 'right'
┌──────── title ┐
│foo bar foo bar│
└───────────────┘

padding

Type: number
Default: 0
Space between the text and box border.

margin

Type: number
Default: 0
Space around the box.

width

Type: number
Default: 0
Width of the box.

expand

Type: bool
Default: False
Expand the box to the terminal width.

border_color

Type: str
Values: "black" "red" "green" "orange" "blue" "purple" "cyan" "lightgrey" "darkgrey" "lightred" "lightgreen" "yellow" "lightblue" "pink" "lightcyan"
Color of the box border.

text_alignment

Type: str
Default: left
Values: left center right
Alignment of the text inside the box.

text_color

Type: str
Values: "black" "red" "green" "orange" "blue" "purple" "cyan" "lightgrey" "darkgrey" "lightred" "lightgreen" "yellow" "lightblue" "pink" "lightcyan"
Color of the text inside the box.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textpanel-1.0.1.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

textpanel-1.0.1-py2.py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page