Skip to main content

提供创建命令行程序工具的模块,包含Cosole类。

Project description

A module for creatig commad lie programs. Home-page: UNKNOWN Author: 七分诚意 qq:3076711200 邮箱:3416445406@qq.com Author-email: 3416445406@qq.com License: UNKNOWN Description: NAME console_tool

DESCRIPTION 模块名称 ========

console_tool

简介

提供创建命令行程序工具的模块,包含Console类。
A module for creating command line programs.

包含的类 CLASSES

类继承顺序:

builtins.object::
    ColoredTextWrapper
    Console
colorama.ansi.AnsiCursor(builtins.object)::
    Cursor

class Console

bell(self, times=1, delay=False)

将振铃符发送至终端,发出响铃声。 times:响铃次数 delay:开始响铃后是否立即返回,默认为False。

clear(self)

清除命令行窗口中的所有文本, 这将调用系统的cls或clear命令。

color(self, backcolor=’’, forecolor=’’)::

改变命令行窗口的前景和背景颜色 与coloredtext方法不同,color改变整个窗口的颜色 该方法调用系统的color命令 如:

color("blue","green") -- 设置前景颜色为绿色,背景颜色为蓝色
color() -- 恢复默认颜色

可用的颜色: black, blue, green, aqua, red, purple, yellow, white, gray, light_blue, light_green, light_aqua, light_red, light_purple, light_yellow, bright_white

coloredtext(self, string, color=’white’, highlight=None, *args, end=’n’, flush=False, reset=True):

输出一段带颜色的文本
如:coloredtext("Hello world!",color="green",highlight="black","bold") --
输出绿色、加粗的文字'Hello world!'
别名: ctext

colorize(self, stdout=’blue’, stderr=’red’, bold=True):

初始化带颜色的输出,类似于IDLE。
colorize(stdout="cyan",stderr="magenta") - 设置输出消息为青色,错误消息为紫色。
colorize(stderr=None) - 只设置输出消息(sys.stdout)的颜色。
input(self, prompt=’’, chars_to_read=None, **kwargs)::

获取用户的输入。 prompt:提示(默认显示为白色) chars_to_read:要从sys.stdin读取多少个字符

print_slowly(self, iterable_of_str, delay=0, *args, **kwargs)::

缓慢地打印出一段文本 iterable_of_str:待打印的内容(字符串或可迭代对象)

reset(self)::

与colorize方法相反,停止带颜色的输出。

title(self, title)::

设置命令行窗口标题。

class Cursor

Cursor(outfile=sys.stdout mode=’w’ encoding=’utf-8’)

命令行中的光标类

Method resolution order:

Cursor colorama.ansi.AnsiCursor builtins.object

Methods defined here:

__init__(self, outfile=<_io.TextIOWrapper name=’<stdout>’ mode=’w’ encoding=’utf-8’>)

Initialize self. See help(type(self)) for accurate signature.

down(self, distance=1)

向下移动光标,距离为distance。

left(self, distance=1)

向左移动光标,距离为distance。

pos(self, x=1, y=1)

移动光标至指定位置(x,y)。 如果不提供参数x,y,则移动光标至屏幕左上角。

right(self, distance=1)

向右移动光标,距离为distance。

up(self, distance=1)

向上移动光标,距离为distance。

class ColoredTextWrapper(builtins.object)

ColoredTextWrapper(file=<_io.TextIOWrapper name=’<stdout>’ mode=’w’ encoding=’utf-8’>, color=’white’, bold=True)

在命令行提供带颜色的输出消息,类似于idle

__init__(self, file=<_io.TextIOWrapper name=’<stdout>’ mode=’w’ encoding=’utf-8’>, color=’white’, bold=True)

Initialize self. See help(type(self)) for accurate signature.

flush(self)

write(self, string)

示例代码 EXAMPLES

c=Console() #初始化Console对象
c.colorize()
c.title("console_tool.py (Test)")
c.coloredtext("Hello world!","green","magenta","blink") # 输出绿色的Hello world!

VERSION

1.1.2

AUTHOR

七分诚意 qq:3076711200 邮箱:3416445406@qq.com

Keywords: terminal,command-line,console Platform: UNKNOWN Classifier: Environment :: Console Classifier: Programming Language :: Python Classifier: Topic :: Terminals

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

console-tool-1.1.2.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file console-tool-1.1.2.tar.gz.

File metadata

  • Download URL: console-tool-1.1.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.2

File hashes

Hashes for console-tool-1.1.2.tar.gz
Algorithm Hash digest
SHA256 63f9543d9221a20cbcccdb9c2cf724f517e4ea63f20773661398ba2e8ba5db6e
MD5 0f1086587644decc693933b25d16c5b6
BLAKE2b-256 ca4c417543d243d88cb90cc58c1656a5db9c27d0de353fd7d212cbf28ee64baa

See more details on using hashes here.

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