Skip to content

Create styled and interactive text in terminals using a modern, declarative syntax.

License

Notifications You must be signed in to change notification settings

jyuhuan/neonsign

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NeonSign

NeonSign is a Python library for styling terminal text and creating simple text-based user interfaces, offering a modern declarative syntax.

With NeonSign, you can simply describe the colors, effects and layout your terminal text should have, without having to work with terminal color commands or box drawing characters manually.

Feature highlights:

  • Style a string using colors and text effects. Best for highlighting a few words in a single line,

  • Style a block of text using colors, effects and layouts. Best for printing contents organized as a list, table, or

  • Create a simple text-based UI, when you need interactivity. For an early prototype of the text user interface (TUI) feature, see here.

Examples

Styled text strings

Example Code Result
from neonsign import s, Color

print(
    s('Hello, world!')
    .padded()
    .foreground(Color.BRIGHT_WHITE)
    .background(Color.BRIGHT_BLUE)
    .bold()
    .blinking()
)

Blinking text:

from neonsign import s, Color

print(
    s(
        s('INFO')
        .padded()
        .foreground(Color.BLACK)
        .background(Color.BRIGHT_WHITE)
        .bold(),
        ' ',
        'An example message'
    )
)

print(
    s(
        s('WARN')
        .padded()
        .foreground(Color.BLACK)
        .background(Color.BRIGHT_YELLOW)
        .bold(),
        ' ',
        s('An example message')
        .foreground(Color.YELLOW)
    )
)

print(
    s(
        s('ERROR')
        .padded()
        .foreground(Color.BRIGHT_WHITE)
        .background(Color.BRIGHT_RED)
        .bold()
        .blinking(),
        ' ',
        s('An example message')
        .foreground(Color.RED)
    )
)

Color-coded logger messages:

Styled text blocks

Text-based UI (early prototype)

About

Create styled and interactive text in terminals using a modern, declarative syntax.

Resources

License

Stars

Watchers

Forks