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()
Здравствуйте, Как я могу обновить индикатор выполнения на основе завершения потоков. Т.е. у меня есть 16530 ссылок на изображения, которые я пытаюсь загрузить, и я хочу создать Progressbar
, который показывает ход загрузки.
Функция download_image
довольно длинная, поэтому я не включал вопрос, но в основном это requests
и запись в файл.