I need a progress to show during file download for Python 3. I have seen a few topics on Stackoverflow, but considering that I\'m a noob at programming and nobody posted a
I think this piece of code can help you. I'm not quite sure it's exactly what you want. At least it should give you something to work on.
import tkinter
from tkinter import ttk
from urllib.request import urlopen
def download(event):
file = urlopen('http://www.python.org/')
output = open('downloaded_file.txt', 'wb')
lines= file.readlines()
i = len(lines)
for line in lines:
output.write(line)
pbar.step(100/i)
output.close()
file.close()
root = tkinter.Tk()
root.title('Download bar')
pbar = ttk.Progressbar(root, length=300)
pbar.pack(padx=5, pady=5)
btn = tkinter.Button(root, text="Download")
# bind to left mouse button click
btn.bind("", download)
btn.pack(pady=10)
root.mainloop()
This works, I've tried it.