All Projects → bczsalba → pytermgui

bczsalba / pytermgui

Licence: MIT license
Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pytermgui

ansicolor
A JavaScript ANSI color/style management. ANSI parsing. ANSI to CSS. Small, clean, no dependencies.
Stars: ✭ 91 (-92.83%)
Mutual labels:  console, ansi, ansi-escape-codes, ansi-escape-sequences
strip-ansi-stream
Strip ANSI escape codes
Stars: ✭ 32 (-97.48%)
Mutual labels:  console, ansi, ansi-escape-codes
Chalk
🖍 Terminal string styling done right
Stars: ✭ 17,566 (+1283.15%)
Mutual labels:  console, ansi, ansi-escape-codes
Termenv
Advanced ANSI style & color support for your terminal applications
Stars: ✭ 555 (-56.3%)
Mutual labels:  console, ansi, tui
ansiart2utf8
Processes legacy BBS-style ANSI art (ACiDDraw, PabloDraw, etc.) to UTF-8. Escape codes and line endings are processed for terminal friendliness.
Stars: ✭ 32 (-97.48%)
Mutual labels:  console, ansi, ansi-escape-codes
yachalk
🖍️ Terminal string styling done right
Stars: ✭ 131 (-89.69%)
Mutual labels:  console, ansi, ansi-escape-codes
Smenu
smenu started as a lightweight and flexible terminal menu generator, but quickly evolved into a powerful and versatile CLI selection tool for interactive or scripting use.
Stars: ✭ 1,906 (+50.08%)
Mutual labels:  console, tui
Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (-86.38%)
Mutual labels:  console, tui
xplr
A hackable, minimal, fast TUI file explorer
Stars: ✭ 2,271 (+78.82%)
Mutual labels:  console, tui
Asciimatics
A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Stars: ✭ 2,869 (+125.91%)
Mutual labels:  console, tui
Phetch
🐭 quick lil gopher client for your terminal
Stars: ✭ 108 (-91.5%)
Mutual labels:  console, tui
S Tui
Terminal-based CPU stress and monitoring utility
Stars: ✭ 2,825 (+122.44%)
Mutual labels:  console, tui
Finalcut
A text-based widget toolkit
Stars: ✭ 244 (-80.79%)
Mutual labels:  console, tui
Kubebox
⎈❏ Terminal and Web console for Kubernetes
Stars: ✭ 1,855 (+46.06%)
Mutual labels:  console, tui
Lazyhub
lazyhub - Terminal UI Client for GitHub using gocui.
Stars: ✭ 133 (-89.53%)
Mutual labels:  console, tui
log-utils
Basic logging utils: colors, symbols and timestamp.
Stars: ✭ 24 (-98.11%)
Mutual labels:  console, ansi
Clrcli
CLRCLI is an event-driven library for building line-art user interfaces in C#/.Net command-line applications.
Stars: ✭ 124 (-90.24%)
Mutual labels:  console, tui
Mitype
Typing speed test in terminal
Stars: ✭ 241 (-81.02%)
Mutual labels:  console, typing
tt
Practicing touch typing, and monitor your typing speed using your own text files
Stars: ✭ 68 (-94.65%)
Mutual labels:  typing, tui
go-color
A lightweight, simple and cross-platform package to colorize text in terminals
Stars: ✭ 65 (-94.88%)
Mutual labels:  console, ansi

title

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!

pip3 install pytermgui

PyPi project Code quality

Twitter Buy Me A Coffee donate button

Why?

Mostly because terminals are cool, but creating terminal apps has historically been difficult. PyTermGUI aims to provide a simple, readable and modular way to make the app of your dreams!

Terminal apps are (often):

  • Easier to install
  • Faster & more resource efficient
  • Less prone to differences between environments (no IE7 here!)

...than their web or native counterparts.

How?

We provide a couple of things to make your life easier:

  • Sensible abstractions over most terminal standards
  • A fully-fledged, desktop-inspired window manager system with modals and completely customizable windows
  • Mouse support out of the box with 0 configuration
  • YAML (or Python) based styling engines
  • TIM, our markup language for creating styled terminal text with expressive text, including systems for aliases & macros
  • A bunch of things I can't think of right now 🙂

Additionally, there are a couple of neat tools to make your general Python development easier:

  • An inspection utility
  • A pretty printer for both the REPL and IPython
  • A way to create SVG and HTML screenshots of your terminal

Examples

All images below are generated directly from the source displayed by a PyTermGUI-powered SVG exporter tool, Termage.

Your first application, a simple clock:

import time

import pytermgui as ptg

def macro_time(fmt: str) -> str:
    return time.strftime(fmt)

ptg.tim.define("!time", macro_time)

with ptg.WindowManager() as manager:
    manager.layout.add_slot("Body")
    manager.add(
        ptg.Window("[bold]The current time is:[/]\n\n[!time 75]%c", box="EMPTY")
    )

Since strings are converted into the Label widget, and all widgets use markup for styling, we can use a custom-defined TIM macro function to return the current time. After running the above, you should see something like:

Clock example output

For something a bit more in-depth, see this contact form inspired by asciimatics' example:

import pytermgui as ptg

CONFIG = """
config:
    InputField:
        styles:
            prompt: dim italic
            cursor: '@72'
    Label:
        styles:
            value: dim bold

    Window:
        styles:
            border: '60'
            corner: '60'

    Container:
        styles:
            border: '96'
            corner: '96'
"""

with ptg.YamlLoader() as loader:
    loader.load(CONFIG)

with ptg.WindowManager() as manager:
    window = (
        ptg.Window(
            "",
            ptg.InputField("Balazs", prompt="Name: "),
            ptg.InputField("Some street", prompt="Address: "),
            ptg.InputField("+11 0 123 456", prompt="Phone number: "),
            "",
            ptg.Container(
                "Additional notes:",
                ptg.InputField(
                    "A whole bunch of\nMeaningful notes\nand stuff", multiline=True
                ),
                box="EMPTY_VERTICAL",
            ),
            "",
            ["Submit", lambda *_: submit(manager, window)],
            width=60,
            box="DOUBLE",
        )
        .set_title("[210 bold]New contact")
        .center()
    )

    manager.add(window)

This showcases the YAML-based config system, as well as some additional API. I recommended checking out the source file to see how the submit callback works.

Contact form example output

Not a fan of colors? We've got you!

PyTermGUI is one of the only TUI libraries that offers NO_COLOR support that doesn't suck ruin the usability & design of your apps.

This is how the above example looks like with the environment variable NO_COLOR set to anything. Note how contrast between colors is retained, as well as the inclusion of background colors:

Contact form NO_COLOR output

Older terminals? No problem!

We use algorithms based on human vision to convert and downgrade colors when the current terminal emulator doesn't support them. Here is a cool screenshot:

Contact form NO_COLOR output

Disclaimer: Termage currently doesn't play nicely to changing colorsystems during runtime, so this image had to be captured natively :(

Questions? See the docs!

Pretty much every single name in the library, private or public, has an insightful dockstring attached to it, and we are accumulating a growing amount of walkthrough-based documentations articles. See 'em all on the doc website!

Contributions, issues et al.

If you have any problems using the library, feel free to open up a discussion or raise an issue ticket. If you would prefer to hack on the library yourself, see the contribution guidelines. Pull requests are encouraged, but make sure you aren't trying to fix an issue that others are already working on, for your own sake. 🙂

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].