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.

Example

PyConText.Console.get_size()

clear()

Clears the console screen.

Parameters None

Returns None

Example

PyConText.Console.clear()

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

Example

PyConText.Cursor.move(0, 0)

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.

Example

PyConText.Cursor.get_cursor_position()

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

Example

PyConText.Widget.input("Enter your name")

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

Example

PyConText.Widget.radio([1,2,3])

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

Example

PyConText.Widget.output("Hello World", alignment="center")

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.2.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.

modulepycontext-0.0.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modulepycontext-0.0.2.tar.gz
  • Upload date:
  • Size: 4.9 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.2.tar.gz
Algorithm Hash digest
SHA256 ff878d3a295edef91a9606a374374f4d149b3accf93e24703f1e39455aaaaa58
MD5 8b06479a0df8f23bc26f15a80293681f
BLAKE2b-256 ac0e5ec2b71ac9d677738541c3bad83611e194ed886fd13c335a892df5f991d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for modulepycontext-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 57b7e7ba651d00e99116fbbcd6967cdde4f77002ca6f1356a45bd943886f3964
MD5 af9ee338cd0790f84d3acb966a958b93
BLAKE2b-256 67e2765d7866eab3ab04d3f9a8263c1cb924336e54b38fc98a9ea836a319416c

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