Skip to main content

一个在终端中输出色彩斑斓、颜色多样内容以及快捷输入的强大工具。A powerful tool for outputting colorful content and enabling quick input in the terminal.

Project description

NbCmdIO: A Powerful Tool for Terminal Colors and Interaction

简体中文 PyPI Version License

Downloads Python Versions

Terminal Art

NbCmdIO is a powerful Python library that transforms ordinary command-line terminals into vibrant visual canvases and robust interactive platforms! Say goodbye to monotonous black-and-white outputs and welcome the world of true RGB colors; farewell to clunky text interfaces and embrace precise cursor control and input capture capabilities.

🌟 Core Features

⚡ Chainable Calls

  • Set cursor positions and styles anytime, anywhere—quick, convenient, and easy to read!
prt[row, col].bold().fg_red("text")

🎨 True-Color RGB Terminal Styling

  • Supports 24 bit RGB and HEX formats for foreground and background colors
  • Includes default colors: Black, Red, Green, etc.
  • Supports effects like Bold, Underline, Italics, etc.
  • True-color image display, with each character representing two pixels for enhanced resolution nbcmdio.prt.drawIMG
  • Displays ASCII grayscale images

🖱️ Character-Level Cursor Control

  • Precise character-level cursor positioning
  • Save/restore cursor positions
  • Get cursor position

📦 Dynamic Area Management

  • Create independently updatable regions
  • Supports nested regions

⌨️ Input Capture (In Progress)

  • Single-key unbuffered reading
  • Shortcut combination detection

🚀 Quick Start

Installation

pip install nbcmdio

Basic Usage

from nbcmdio import prt

def NbCmdIO():
    lavender = "#ccf"
    # Clear screen and set terminal title
    prt.cls().setTitle("NbCmdIO")
    # On line 2, bold, blue text, center-aligned with gradient background
    title = "        NbCmdIO  by  Cipen        "
    prt[2].bold().fg_hex("#00f").gotoCenterOffset(getStringWidth(title))
    prt.drawHGrad((230, 92, 0), (249, 212, 35), string=title)
    WIDTH = 40
    HEIGHT = 10
    center_offset = (prt.size_col - WIDTH) // 2
    # Draw a rectangle with foreground #CCF at (3, center_offset) and set the new region to this rectangle
    prt.fg_hex(lavender)[3, center_offset].drawRect(WIDTH, HEIGHT)
    prt.fg_blue()[0, 3](" NbCmdIO ").bold()[0, WIDTH - 8](prt.__version__)
    b2 = "  "
    # Enter context (styles aren't auto-reset inside), add square color blocks at the 4 corners
    with prt.bg_hex(lavender):
        prt[1, 1](b2)[1, WIDTH - 1](b2)
        prt[HEIGHT, 1](b2)[HEIGHT, WIDTH - 1](b2)
    # Add styles within strings (ensure characters are defined separately, not directly in chain calls)
    line1 = f"Welcome to {prt.bold().bg_hex(lavender).fg_hex('#000')} NbCmdIO "
    line2 = "Print your string colorfully!"
    # Save and reuse styles (includes position, color, effects)
    head_style = prt.fg_red().bold().makeStyle()
    prt[1].use(head_style).alignCenter(line1)# Use style in new region's first line for centered text
    prt[2].use(head_style).alignCenter(line2)
    prt[3, 3].fg_grey().drawHLine(WIDTH - 4)
    
    text = r"""
 _____    _____    _______ 
|  _  \  |  _  \  |__   __|
| |__) | | |__) |    | |   
|  __ /  |  _  <     | |   
| |      | | \ \     | |   
|_|      |_|  \_\    |_|   """[1:]
    lines = text.splitlines()
    chr1 = [l[:8] for l in lines]
    chr2 = [l[8:18] for l in lines]
    chr3 = [l[18:] for l in lines]
    prt.fg_red().bold()[4, 8].printLines(chr1)
    prt.fg_green().bold()[4, 16].printLines(chr2)
    prt.fg_blue().bold()[4, 25].printLines(chr3)
    
    # Move cursor to next line in region, then exit
    prt[HEIGHT + 1].setOriginTerm().end()
    prt.gotoCenterOffset(70)
    # Draw a gradient bar, move down 2 lines, test terminal color support
    prt.drawHGrad((51, 101, 211), (190, 240, 72), 70).end(2)
    prt.test().end()

NbCmdIO()

🔮 Future Roadmap

Version Features Status
v1.0 RGB Color Support, Area Management ✅ Released
v2.0 Input Capture System 📅 Planned
v3.0 Terminal UI Component Library 💡 Conceptualizing

🌍 Community Contributions

We welcome all forms of contributions! Whether you:

  • Discover and report issues
  • Submit feature requests
  • Contribute code
  • Create documentation
  • Share creative use cases

📜 Open-Source License

NbCmdIO uses the MIT License—feel free to use it in both commercial and personal projects!

✨ Experience Terminal Magic Now!

pip install nbcmdio

Ready to elevate your command-line experience to a whole new dimension? NbCmdIO is waiting to bring your terminal to life!


📜 Changelog

  • 1.8.1 Completed all basic Output features, major update
  • 1.8.2 Initial unbuffered single-key input capture
  • 1.8.3 Fixed issues, added quick PS1 batch files, separated style module
  • 1.8.4 Added multi-line region printing, separated utils
  • 1.8.5 feat: drawHGrad (gradient), drawIMG (terminal image display)
  • 1.8.6 improve: added validation for loc, size feat: drawImageStr
  • 1.8.63 feat: Output.playGif
  • 1.8.64 fix: height overflow in Output.valSize

🙏 Acknowledgments

  • colorama for CSI terminal title methods
  • timg for ASCII grayscale image methods and fixing Issue #4
  • curses for hline, vline, rectangle methods

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

nbcmdio-1.8.64.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nbcmdio-1.8.64-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file nbcmdio-1.8.64.tar.gz.

File metadata

  • Download URL: nbcmdio-1.8.64.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.8

File hashes

Hashes for nbcmdio-1.8.64.tar.gz
Algorithm Hash digest
SHA256 3450bced3015bd9e2ee2f706d91473c64c364c6b803d1c16fe1555281ae47514
MD5 7b5bd0d1ee0ebe21148a64cad9cd8901
BLAKE2b-256 76d010d40fd4951e9d36a108e62bf131ef00536f61703de318062f104bcdf180

See more details on using hashes here.

File details

Details for the file nbcmdio-1.8.64-py3-none-any.whl.

File metadata

  • Download URL: nbcmdio-1.8.64-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.8

File hashes

Hashes for nbcmdio-1.8.64-py3-none-any.whl
Algorithm Hash digest
SHA256 4f13beb1be4024be105beb3fc68181a4b127dc364251b69dc109f722317451da
MD5 3479858d7f8a1896321cc5e75256709c
BLAKE2b-256 a52eb2c3b4d595020d688abb5105e508bb7605583b207cba8917c4a038f0e261

See more details on using hashes here.

Supported by

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