1 Star 0 Fork 0

mamh-mixed/python-cookbook

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
loader.py 753 Bytes
一键复制 编辑 原始数据 按行查看 历史
slowy07 提交于 2022-01-30 09:33 +08:00 . refactor: clean code
"""
Shaurya Pratap Singh
@shaurya-blip
Shows loading message while doing something.
"""
import itertools
import threading
import time
import sys
# The task is not done right now
done = False
def animate(message="loading", endmessage="Done!"):
for c in itertools.cycle(["|", "/", "-", "\\"]):
if done:
break
sys.stdout.write(f"\r {message}" + c)
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write(f"\r {endmessage} ")
t = threading.Thread(
target=lambda: animate(message="installing..", endmessage="Installation is done!!!")
)
t.start()
# Code which you are running
"""
program.install()
"""
time.sleep(10)
# Then mark done as true and thus it will end the loading screen.
done = True
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mamh-mixed/python-cookbook.git
git@gitee.com:mamh-mixed/python-cookbook.git
mamh-mixed
python-cookbook
python-cookbook
master

搜索帮助