“光环”的临时分叉:python中漂亮的终端微调器
frkl.halo的Python项目详细描述
光环
Beautiful spinners for terminal, IPython and Jupyter
安装
$ pip install halo
用法
fromhaloimportHalospinner=Halo(text='Loading',spinner='dots')spinner.start()# Run time consuming work here# You can also change properties for spinner as and when you wantspinner.stop()
或者,可以将halo与Python的with
语句一起使用:
fromhaloimportHalowithHalo(text='Loading',spinner='dots'):# Run time consuming work here
最后,您可以使用halo作为装饰:
fromhaloimportHalo@Halo(text='Loading',spinner='dots')deflong_running_function():# Run time consuming work herepasslong_running_function()
API
Halo([text|text_color|spinner|animation|placement|color|interval|stream|enabled])
text
类型:str
文本与微调器一起显示。
text_color
类型:str
值:grey
,red
,green
,yellow
,blue
,magenta
,cyan
,white
微调器文本的颜色。默认为None
。
spinner
type:str|dict
如果是字符串,它应该是给定json文件中列出的微调器之一如果一个dict被传递,它应该定义interval
和frames
例如:
{'interval':100,'frames':['-','+','*','+','-']}
默认为dots
微调器。对于windows用户,它默认为line
微调器。
animation
类型:str
值:bounce
,marquee
如果文本太大且不适合终端,则应用于该文本的动画。如果未定义动画,则文本将被省略
placement
类型:str
值:left
,right
微调器应显示文本的哪一侧。默认为left
color
类型:str
值:grey
,red
,green
,yellow
,blue
,magenta
,cyan
,white
微调器的颜色。默认为cyan
interval
类型:float
每帧之间的间隔默认为微调器间隔(推荐)。
stream
类型:file
写入输出的流默认为sys.stdout
enabled
类型:bool
启用或禁用微调器。默认为True
。
方法
以下是可用的方法:
spinner.start([text])
启动微调器如果通过text
,则设置为微调器文本。返回实例。
spinner.stop()
停止并清除微调器。返回实例。
spinner.clear()
清除微调器返回实例。
spinner.render()
手动渲染新帧返回实例。
spinner.frame()
返回要呈现的下一帧
spinner.succeed([text])
text
:type:str
停止微调器并将符号更改为✔
如果提供文本,则将其持久化,否则将持久化当前文本。返回实例
spinner.fail([text])
text
:type:str
停止微调器并将符号更改为✖
。如果提供文本,则将其持久化,否则将持久化当前文本返回实例
spinner.warn([text])
text
:type:str
停止微调器并将符号更改为⚠
如果提供文本,则将其持久化,否则将持久化当前文本。返回实例
spinner.info([text])
text
:type:str
停止微调器并将符号更改为ℹ
。如果提供文本,则将其持久化,否则将持久化当前文本返回实例
spinner.stop_and_persist([symbol|text])
停止微调器并更改符号和文本。返回实例
symbol
类型:str
替换微调器的符号。默认为' '
。
text
类型:str
要持久化的文本。默认为实例文本。
spinner.text
更改微调器的文本
spinner.color
更改微调器的颜色
spinner.spinner
更改微调器本身。
如何贡献?
有关详细信息,请参见Contributing guidelines。
喜欢吗?
本回购协议表示支持。让我知道你喜欢在Twitter上看。 另外,共享project
相关
- py-spinners-Python中的微调器
- py-log-symbols-Python中的日志符号
- ora-优雅的javascript终端微调器(这个项目背后的灵感)
许可证
MIT曼拉吉·辛格