Skip to main content

A small python library to simulate typing in the console and custom text formatting.

Project description

KeyFlow

KeyFlow is a Python library that provides interactive console printing with a simulated typing effect and customizable text formatting. It allows you to create dynamic and engaging command-line interfaces for your Python applications.

Features

  • Simulated typing effect: Display text with a realistic typing animation.
  • Customizable formatting: Apply foreground and background colors, underline, bold, and italics to your printed text.
  • Error simulation: Introduce random typing errors to make the output more human-like.
  • Prompt input: Display prompts and wait for user input with support for various input validation options.
  • Integration with PyInputPlus: Option to use PyInputPlus functions for input handling.
  • Easy-to-use API: Simple and intuitive functions for printing and input.

Installation

You can install KeyFlow using pip:

pip install keyflow

Usage

kfprint

The kfprint function prints text with a simulated typing effect and supports custom foreground and background colors.

from keyflow import kfprint

kfprint(text, speed=0.2, retype=None, fore_color=None, back_color=None, typing=True, error=0.2, underline=False, bold=False, italics=False)

Parameters

  • text (str): The text to be printed.
  • speed (float, optional): The typing speed in seconds per character. Default is 0.2.
  • retype (str, optional): Text to be retyped after printing. Default is None.
  • fore_color (str, optional): The foreground color code or name to apply to the text. Default is None.
  • back_color (str, optional): The background color code or name to apply to the text. Default is None.
  • highlight (str, optional): Text to be highlighted with the fore_color and back_color, works only when typing is set to false. Default is None.
  • typing (bool, optional): Whether to simulate typing effect. Default is True.
  • error (float, optional): The probability of making an error while typing. Default is 0.2.
  • underline (bool, optional): Whether to underline the text. Default is False.
  • bold (bool, optional): Whether to bold the text. Default is False.
  • italics (bool, optional): Whether to italicize the text. Default is False.

kfinput

The kfinput function displays text with a simulated typing effect, waits for user input, and returns the entered value.

from keyflow import kfinput

kfinput(text, speed=0.2, retype=None, fore_color=None, back_color=None, typing=True, use_pyip=None, pyip_params={}, error=0.2, underline=False, bold=False, italics=False)

Parameters

  • text (str): The text to be displayed as a prompt.
  • speed (float, optional): The typing speed in seconds per character. Default is 0.2.
  • retype (str, optional): Text to be retyped after printing. Default is None.
  • fore_color (str, optional): The foreground color code or name to apply to the text. Default is None.
  • back_color (str, optional): The background color code or name to apply to the text. Default is None.
  • highlight (str, optional): Text to be highlighted with the fore_color and back_color, works only when typing is set to false. Default is None.
  • typing (bool, optional): Whether to simulate typing effect. Default is True.
  • use_pyip (callable, optional): A pyinputplus function to use for input. Default is None.
  • pyip_params (dict, optional): Additional parameters to pass to the use_pyip function. Default is an empty dictionary.
  • error (float, optional): The probability of making an error while typing. Default is 0.2.
  • underline (bool, optional): Whether to underline the text. Default is False.
  • bold (bool, optional): Whether to bold the text. Default is False.
  • italics (bool, optional): Whether to italicize the text. Default is False.

Note: When typing, you can press the spacebar to pause and resume the typing animation.

License

KeyFlow is released under the MIT License. You are free to use, modify, and distribute this library for both commercial and non-commercial purposes. Please see the LICENSE file for more details.

GitHub Repository

Feel free to explore the repository, submit issues, and contribute to the project.

To clone the repository, run the following command:

git clone https://github.com/aneousion/keyflow

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

keyflow-1.1.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

keyflow-1.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file keyflow-1.1.1.tar.gz.

File metadata

  • Download URL: keyflow-1.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for keyflow-1.1.1.tar.gz
Algorithm Hash digest
SHA256 173b54137c5b239ebd87e74ad02ead25c4c5d7836ac56120bc9a5504ec720985
MD5 c28e0b6882fcbe101ea49aa9a6ad6a04
BLAKE2b-256 2d1957a95217377bdb4e06ee40794c63aca6bb07697ea092f35f4e0d6ef5da2c

See more details on using hashes here.

File details

Details for the file keyflow-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: keyflow-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for keyflow-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6faf8f64ce80361c78b37e7360ff56cd8c4f9211416bf0a5f29eb4d3dcf9088a
MD5 7a911bd793af42c3c5d4bb94abbd1004
BLAKE2b-256 9b8e2b6cfdbebed35f118c73d66fca90770b67345957171171fb707bb6b5621c

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