python - 用进度条复制文件?
问题描述
我正在制作一个简单的程序,它使用 tkinter 和 shutil 来复制文件,没什么特别的。问题是没有迹象表明该过程何时完成,如果我正在复制大文件夹,程序会冻结,直到完成复制。我想要一个进度条,但不知道如何在 tkinter 中实现它。
from tkinter import *
from tkinter import filedialog
import shutil
def browseFiles():
filename = filedialog.askdirectory(initialdir="/", title="Select a directory")
label_file_explorer.configure(text="Directory Opened: " + filename, bg="grey")
shutil.copytree(filename, r"J:\PCmover\ziptest\test")
window = Tk()
window.title('Beringia')
window.geometry("700x500")
window.config(background="white")
label_file_explorer = Label(window, width=100, height=4, bg="white", fg="blue")
button_explore = Button(window, text="Choose directory", command=browseFiles)
button_exit = Button(window, text="Quit", command=exit)
softwarename=Label(window, text="Welcome to Beringia!", width=100, height=4, fg="blue")
ver=Label(window, text="Ver 1.0", bg="grey", fg="blue")
label_file_explorer.place(x=0, y=200)
button_explore.place(x=305, y=80)
button_exit.place(x=335, y=120)
softwarename.place(x=0, y=0)
ver.place(x=659, y=479)
window.mainloop()
解决方案
推荐阅读
- python - 将映射 long/lat 代码从 R (sp pkg) 转换为 Python
- javascript - 当通过nodemailer -node.js作为电子邮件发送时,html中的图像不显示?
- python - 使用 Flask-Dropzone 一次上传多个文件
- amazon-web-services - 每个通配符子域指向不同的IP地址
- c# - 如何忽略继承中的歧视列
- pandas - Pandas:将多个列键上的两个数据集与匹配行的条件联合起来
- excel - Excel添加在启动时不加载
- vba - 如何在 VBA x64 中使用 CallWindowProc?
- php - 将信息从列中提取到 for 循环中
- python - Python 成员运算符“在”TensorFlow 数据集中