def save_with_status(selector, host, port):
fn = asksaveasfilename(parent=top, title="Save file as")
if fn == "":
return
prog_win = Toplevel(top, padx=8, pady=8)
prog_win.title = "Downloading..."
prog_win.transient(top)
prog_win.resizable(FALSE, FALSE)
prog_bar = ttk.Progressbar(
prog_win, orient=HORIZONTAL, length=300, mode="indeterminate")
prog_bar.pack()
try:
with open(fn, "wb") as f:
for i in fetch_data(selector, host, port):
f.write(i)
prog_bar.step()
return True
except Exception as e:
showerror(
parent=top,
title="Error loading content",
message=str(e))
return False
finally:
prog_win.destroy()
评论列表
文章目录