from PIL import Image
from PIL import ImageDraw
def progressBar(imgPath, bgcolor, color, x, y, w, h, progress):
im = Image.open(imgPath)
drawObject = ImageDraw.Draw(im)
'''BG'''
drawObject.ellipse((x+w,y,x+h+w,y+h),fill=bgcolor)
drawObject.ellipse((x,y,x+h,y+h),fill=bgcolor)
drawObject.rectangle((x+(h/2),y, x+w+(h/2), y+h),fill=bgcolor)
'''PROGRESS'''
if(progress<=0):
progress = 0.01
if(progress>1):
progress=1
w = w*progress
drawObject.ellipse((x+w,y,x+h+w,y+h),fill=color)
drawObject.ellipse((x,y,x+h,y+h),fill=color)
drawObject.rectangle((x+(h/2),y, x+w+(h/2), y+h),fill=color)
'''SAVE'''
im.save(imgPath)
imgPath 图片路径
bgcolor 进度条背景
color 进度条颜色
x 横坐标位置
y 纵坐标位置
w width
h height
r 进度(0-1)