tkinter updating progress bar on thread progress

若如初见. 提交于 2020-05-29 09:58:22

问题


from tkinter import * 
from tkinter.ttk import *
import threading
import numpy as np
def bar():
    #function to display progress
    pass
with open('/home/user154/test.txt') as f:
    total=f.read().split('\n')
root = Tk()
links = list(filter(None, total)) #16530 links
threads =[]
#creating chunks of length 10
chunks = [i.tolist() for i in np.array_split(links, 10) if i.size>0]
# Progress bar widget 
progress = Progressbar(root, orient = HORIZONTAL, 
              length = len(links), mode = 'determinate') 
#launching the threads
for lst in chunks:
    threads.append(threading.Thread(target=download_image, args=(lst)))
for x in threads:
   x.start()
for x in threads:
    x.join()


mainloop()

Hello, How can I Update the progress bar based on threads completion. I.e I have 16530 image links which I am trying to download and want to create a Progressbar which shows the progress of downloading.

The download_image function is pretty long so I didn't include in question but basically it's requests and write to file.

来源:https://stackoverflow.com/questions/60591061/tkinter-updating-progress-bar-on-thread-progress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!