How to update the ttk progress bar on tkinter
NickName:jon_groth34 Ask DateTime:2019-07-24T04:22:45

How to update the ttk progress bar on tkinter

I've got a program that does some simple webscraping. I'm working on giving it to my coworkers to use, but they are unfamiliar with code so I'd like to make a GUI. I've started using tkinter, and I'm currently working on making a progress bar showing where the program is at (it can take up to a couple hours to run). My problem is that I can't seem to get the progress bar to update, and all the online sources use Tkinter, which is an old version. Here is my code:

I've tried updating progressBar['value'] to whatever number I want, but that hasn't been working.

from tkinter import *
from tkinter import ttk
import time


def clicked(progressBar): # runs a couple functions and updates the progress bar when the button is clicked
    num = 0
    for item in range(5):
        # functions go here
        num += 10
        progressBar['value'] = num
        time.sleep(2)

window = Tk()
window.title("Welcome to my app")
window.geometry('600x400')

progressBar = ttk.Progressbar(window, orient='horizontal', length=300, mode='determinate', maximum=100, value=0)
progressBar.grid(columnspan=3, row=2, sticky=(W, E))

btn = Button(window, text="Click me!", command=clicked(progressBar))
btn.grid(column=1, row=1)

window.mainloop()

The tkinter window doesn't open up until 10 seconds after I run the program, and it has the progress bar already at 50% full. I'd like for the bar to slowly increment up, AFTER the button has been clicked. Any advice would be helpful! Thank you!

Copyright Notice:Content Author:「jon_groth34」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/57171675/how-to-update-the-ttk-progress-bar-on-tkinter

More about “How to update the ttk progress bar on tkinter” related questions

How to update the ttk progress bar on tkinter

I've got a program that does some simple webscraping. I'm working on giving it to my coworkers to use, but they are unfamiliar with code so I'd like to make a GUI. I've started using tkinter, and I'm

Show Detail

Update Tkinter progress bar

I've made a python script for downloading a number of files from a website and I'd like to make a progress bar in Tkinter which should update as each file is saved to the computer. I've seen some

Show Detail

ttk progress bar freezing

I want a progress bar that shows the user the download progress. When updating the GUI and downloading at the same time the progress bar freezes, and I understand why but I don't know how to solve ...

Show Detail

Progress bar in Tkinter Python

I have a Python code to run the progress bar on macOS Big Sur here (I copied it from an online tutorial): from tkinter import ttk import tkinter as tk from tkinter.messagebox import showinfo # root

Show Detail

How to create downloading progress bar in ttk?

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 tk...

Show Detail

Tkinter indeterminate progress bar not running

I'm currently creating a Tkinter Gui for Python 2.7 and having trouble working the progress bar. I need to load largish files into my program which takes some time, so I wanted to get a progress ba...

Show Detail

tkinter progress bar with joblib parallel

I would like to make a GUI progress bar to show the progress of Joblib. Here below is what I have done now: import tkinter as tk from tkinter import ttk from tqdm import tqdm from joblib import Par...

Show Detail

Update progress bar from function outside the main class in Python Tkinter

I have initialized a progress bar and want to update it according to the function / thread which is outside the main class of Tkinter. I have tried all the solutions present over here similar to the

Show Detail

Tkinter progress bar with Excel

We have a Pyxll app (Excel app written in python) that makes a bunch of requests to get data when the workbook is opened. We would like to display a loading bar to the user while the requests are b...

Show Detail

how to create a simple progress bar loop in tkinter

Since I can't find an exact thread like this elsewhere I will post this question here, I just started learning Tkinter and facing problems with the progress bar widget. from tkinter import ttk import

Show Detail