用tkinter给Python的GUI应用添加进度条
在开发GUI应用时,进度条能更好的显示某些任务的工作状态,下面整理出了进度条模块代码,可以直接保存为ProgressBar.py使用:
系统:win 10
python版本:python 3.6.5
1. python源码(ProgressBar.py)
#!/usr/bin/python3
# coding:utf-8
'''
class python进度条
1、function init
参数:
1、父窗口 master
2、起始坐标 x, y
3、宽高 width, height
2、function set_fmt
1、背景色 bg
2、前景色 fg
3、边框大小 frame_size
4、文字位置 n上,s下,W左, e右
3、function run
参数:
1、百分比 percentage
2、显示的文字 text
'''
from tkinter import *
pb_x = 0
pb_y = 0
pb_width = 100
pb_height = 20
pb_bg = "white"
pb_fg = "green"
pb_frame_size = 0
canvas = Canvas
class progress:
def __init__(self)