在终端中显示加载条的库。

loadingbar的Python项目详细描述


python加载栏

Travis Test

python模块在终端窗口中显示一个不错的加载条。

安装

转到模块目录并运行:

$ pip install setup.py

或:

$ python3 setup.py install

开始

有3种不同的加载条:

  1. 标准加载杆
  2. 加载尺寸、速度和剩余时间的加载条
  3. 带有以上信息的加载条和一条自定义消息(用于显示详细的加载条)

选项1

没有任何其他信息的标准加载条。

Loading bar option 1

importloadingtotal_file_size=1000# Create a loading bar object with total_file_size in byteslb=loadingbar.LoadingBar(total_file_size)# For every piece of fileforchunkinfile:# Update the loading bar with the len of new datalg.update(len(chunk))# When finished, display a 100% loading barlg.done()

选项2

标准加载条,包含下载的大小、速度、预计到达时间等信息。

Loading bar option 2

importloadingtotal_file_size=1000lb=loadingbar.InfoLoadingBar(total_file_size)# Run as above

选项3

这个特殊的InternetLoadingBar通过计算整体平均时间而不是瞬时速度来平滑速度计算。

importloadingtotal_file_size=1000lb=loadingbar.InternetLoadingBar(total_file_size)# Run as above

选项4

显示消息的加载栏,例如下载的文件名。两个选项:

  • loadingbar.MessageLoadingBar
  • loadingbar.VerboseLoadingBar

Loading bar option 3

importloadingtotal_file_size=1000lb=loadingbar.VerboseLoadingBar(total_file_size)# For every piece of fileforchunkinfile:# Update the loading bar with the len of new datalg.update(len(chunk),"Message to be displayed, such as filename, etc.")# When finished, display a 100% loading barlg.done()

选项5

在加载栏后添加百分比。

  • loadingbar.PercentageLoadingBar(tot_size)Loading bar option 5-1

  • loadingbar.PercentageInfoLoadingBar(tot_size)Loading bar option 5-2

选项6

在加载栏后添加百分比。

  • loadingbar.PercentageBeforeLoadingBar(tot_size)Loading bar option 6-0

  • loadingbar.PercentageBeforeLoadingBarAndInfo(tot_size)Loading bar option 6-1

定制

如果需要新的自定义加载条,可以通过从loading bar类或抽象类iloadingbar继承来实现新的加载条。 有关示例,请参见加载>;loading_bar.py。

许可证

麻省理工学院执照。 请随意使用、分享或改进它。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
带有服务类安卓的java altbeacon   java在OpenXava免费版本中可以创建多个用户吗?   java如何决定定义变量“private”?   java为什么GetMethodID()对不存在的方法不返回NULL?   java Get JComboBox项字符串表示法   java如何在ifs之间设置限制?   java Android错误:IllegalStateException   JavaSpring4MVC语言环境已更改,但JSP对此没有响应   java Netbeans:如何构建。jar文件随附外部文件。jar库?   Spring Petclinic项目Maven编译时出现java错误   声明Java数组增量元素的快速方法   java无法使用相对xpath找到元素   javascript无法更改标题,也无法在操作栏上显示图标   java标签不是一个接一个地动态创建的   java如何使用ThymeLeaf将对象的属性绑定到隐藏字段?   java从EJB无状态会话bean调用CDI会话范围的生产者方法   java为什么num+=array[i]与for循环中的num=num+array[i]的工作方式不同   使用jsonsimple实现jQuery UI自动完成的java JSON格式   JavaFaceletsUI:重复标记中断JSF表单验证