Skip to content

Instantly share code, notes, and snippets.

@tc87
Created March 31, 2020 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tc87/2dd80d668f36e102647ff04305862384 to your computer and use it in GitHub Desktop.
Save tc87/2dd80d668f36e102647ff04305862384 to your computer and use it in GitHub Desktop.
# Draw UI elements.
weights_warning = st.warning("Downloading %s..." % file_path)
progress_bar = st.progress(0)
with open(file_path, "wb") as output_file:
with urllib.request.urlopen(...) as response:
...
while True:
... # Save downloaded bytes to file here.
# Update UI elements.
weights_warning.warning(
"Downloading %s... (%6.2f/%6.2f MB)" %
(file_path, downloaded_size))
progress_bar.progress(downloaded_ratio)
...
# Clear UI elements when done.
weights_warning.empty()
progress_bar.empty()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment