Skip to main content

A windows-only python package for displaying text in the console with format and give console cursor control.

Project description

PyConText

PyConText

PyConText is a Python package for displaying text in the console with format and give console cursor control. Note: It is windows-only and it will not work well if the console window size is keep changing.

Dependencies

PyConText uses the following modules:

  • os
  • shutil
  • keyboard
  • ctypes (and wintypes)

and the following for building and publishing:

  • twine
  • wheel
  • setuptools

Installation

Install the package with pip:

pip install ModulePyConText

Then import it like this:

import PyConText

Examples

The example projects can be downloaded from the releases in Github.

How to use

Console Functions

get_size()

Returns the size of the terminal as a named tuple of two integers, columns and lines.

Parameters None

Returns collections.namedtuple

  • A named tuple of two integers, columns and lines.

clear()

Clears the console screen.

Parameters None

Returns None

Cursor Functions

move(x:int=0, y:int=0)

Moves the cursor to a given position

Parameters x : int

  • The x position of the cursor starting from 0 y : int
  • The y position of the cursor starting from 0

Returns None

get_cursor_position()

Requests the current position of the cursor from the terminal and returns it as a tuple of two integers, the row and column of the cursor.

Parameters None

Returns tuple

  • A named tuple of two integers, the row and column of the cursor. If the operation is unsupported returns None.

Widget Functions

input(prompt: str, end: str = ": ", erase: bool = True)

Reads input from the user and returns it as a string.

Parameters prompt : str

  • The text to display to the user before reading input end : str
  • The string to append to the end of the prompt, defaults to ": " erase : bool
  • Whether to erase the input line after reading, defaults to True

Returns str

  • The input from the user as a string

radio(options: list, selection_character: chr = "*", unselection_character: chr = " ")

Creates a radio button menu from a given list of options

Parameters options : list

  • A list of strings to be used as the options selection_character : chr
  • The character to use to mark the selected option, defaults to "*" unselection_character : chr
  • The character to use to mark the unselected options, defaults to " "

Returns str

  • The selected option as a string

output(output, alignment="left")

Outputs the given string or list of strings to the console, with optional alignment

Parameters output : str or list

  • The string or list of strings to output
  • If it is a list, each element will be printed on a new line alignment : str
  • The alignment of the output, either "left", "center", or "right". Defaults to "left"

Returns None

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

modulepycontext-0.0.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

modulepycontext-0.0.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file modulepycontext-0.0.1.tar.gz.

File metadata

  • Download URL: modulepycontext-0.0.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for modulepycontext-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3544faf19981df084e57c56a063b09041a316279bebe4637374d81cfca96e2ad
MD5 0339750081942f889d61b63f4adac76f
BLAKE2b-256 5ef4b74bb01b81062948a8caac47dd9bf24732859efdb8331db811681e4fb9f8

See more details on using hashes here.

File details

Details for the file modulepycontext-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for modulepycontext-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 29ddb6630bf94b24078c28f741290e490735bb9916d5438ff3b95eecf47600e5
MD5 e5edce822cf94c53d58d53116e9bd538
BLAKE2b-256 c9394eeb55758e4b26325ad5f38eb12250a582cde1610e992c56de5f4f1da9bb

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