0
Guys, here’s the thing, I was doing a progress bar for a download of a file on the web, but it doesn’t work. When I run the code, the Tkinter window is locked and only returns when the download is finished. Does anyone know what I’m missing? I am already 2 days in this problem. Follow the code part below:
def read_bytes(self):
with open(file_name, "wb") as f:
response = requests.get(linkd, stream=True)
total_length = response.headers.get('content-length')
if total_length is None:
f.write(response.content)
else:
dl = 0
total_length = int(total_length)
for data in response.iter_content(chunk_size=4096):
dl += len(data)
f.write(data)
self.bytes = dl
self.progress["value"] = self.bytes
if self.bytes < self.maxbytes:
self.after(100)
elif self.bytes >= self.maxbytes:
self.exit = ttk.Label(self, text="Terminado",
background = 'black',
foreground = 'white')
self.exit.pack()
Thanks bro! I adapted my code with this concept that you presented and apparently worked out great, great explanation. Solved issue :)
– Alexsander Meiniche