Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6532969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:04:06+00:00 2026-05-25T10:04:06+00:00

I want to show a progress bar while downloading a file from the web

  • 0

I want to show a progress bar while downloading a file from the web using the urllib.urlretrive method.

How do I use the ttk.Progressbar to do this task?

Here is what I have done so far:

from tkinter import ttk
from tkinter import *

root = Tk()

pb = ttk.Progressbar(root, orient="horizontal", length=200, mode="determinate")
pb.pack()
pb.start()

root.mainloop()

But it just keeps looping.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:04:07+00:00Added an answer on May 25, 2026 at 10:04 am

    For determinate mode you do not want to call start. Instead, simply configure the value of the widget or call the step method.

    If you know in advance how many bytes you are going to download (and I assume you do since you’re using determinate mode), the simplest thing to do is set the maxvalue option to the number you are going to read. Then, each time you read a chunk you configure the value to be the total number of bytes read. The progress bar will then figure out the percentage.

    Here’s a simulation to give you a rough idea:

    import tkinter as tk
    from tkinter import ttk
    
    
    class SampleApp(tk.Tk):
    
        def __init__(self, *args, **kwargs):
            tk.Tk.__init__(self, *args, **kwargs)
            self.button = ttk.Button(text="start", command=self.start)
            self.button.pack()
            self.progress = ttk.Progressbar(self, orient="horizontal",
                                            length=200, mode="determinate")
            self.progress.pack()
    
            self.bytes = 0
            self.maxbytes = 0
    
        def start(self):
            self.progress["value"] = 0
            self.maxbytes = 50000
            self.progress["maximum"] = 50000
            self.read_bytes()
    
        def read_bytes(self):
            '''simulate reading 500 bytes; update progress bar'''
            self.bytes += 500
            self.progress["value"] = self.bytes
            if self.bytes < self.maxbytes:
                # read more bytes after 100 ms
                self.after(100, self.read_bytes)
    
    app = SampleApp()
    app.mainloop()
    

    For this to work you’re going to need to make sure you don’t block the GUI thread. That means either you read in chunks (like in the example) or do the reading in a separate thread. If you use threads you will not be able to directly call the progressbar methods because tkinter is single threaded.

    You might find the progressbar example on tkdocs.com to be useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use progress bar to show the current progress % the rows
I want to show upload progress bar for my uploads using servlet. I tried
I want to show the progress bar during web service call. I called progress
I want to show a progress bar while my iPhone app is uploading an
I want to show up an progress bar while a download with NSURLConnection is
In my project i want to show the progress bar while uploading files. I
i want to show the progress of copying the file from one folder to
I want to show progress with jquery ui progress bar when an ajax request
I want to display a progress bar while doing some work, but that would
I want to show a progress bar (like wget) how do i keep writing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.