Skip to main content

A cross-platform Python 2/3 module for colorful, boring, text-based terminal programs.

Project description

Bext

A cross-platform Python 2/3 module for colorful, boring, text-based terminal programs.

Basically, use Bext if you want to move the cursor around the terminal window and have colorful text, like some kind of limited curses module (but it works on Windows also.)

TODO - Translate these instructions?

Installation

To install with pip, run:

pip install bext

Functions

  • fg(color)

Sets the foreground color, that is, the color of the text. The color is a string of one of the following colors: black, red, green, yellow, blue, purple, cyan, white, reset, random.

  • bg(color)

Sets the background color, that is, the color of the cell behind the text characters. You "paint" a cell with the background color by printing a space character.

  • size()

Returns a tuple of the (width, height) of the current terminal.

  • clear()

Erase all the text on the screen, paint the entire terminal to the background color, and

  • goto(x, y)

Move the cursor to x, y coordinates on the screen. (0, 0) is the top-left corner of the screen.

Example

import bext, random

width, height = bext.size()

try:
    while True:
        bext.fg('random')
        bext.bg('random')
        x = random.randint(0, width - 1)
        y = random.randint(0, height - 1)

        if x == width -1 and y == height - 1:
            continue # Windows has weird behavior where a character at the end of the row always moves the cursor to the next row.
        bext.goto(x, y)
        print('*', end='')
except KeyboardInterrupt:
    pass

Contribute

If you'd like to contribute to Bext, check out https://github.com/asweigart/bext

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

Bext-0.0.4.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file Bext-0.0.4.tar.gz.

File metadata

  • Download URL: Bext-0.0.4.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.1

File hashes

Hashes for Bext-0.0.4.tar.gz
Algorithm Hash digest
SHA256 d50706743c4337277db4d9372f88b23b90a553534039933e7c51f7fa186b26b1
MD5 32167e42b6fade2b2dd65880fc0e077a
BLAKE2b-256 2390d2337e031347abef0d1e00ddf5a1be4708027d184be2280b9d8bff84d44f

See more details on using hashes here.

Provenance

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