While processing occurs, the screen has to display a progress bar for the user. What is the logic behind this (Python, Tkinter)? How do I make the progress bar appear on the screen while processing is taking place?
While processing occurs, the screen has to display a progress bar for the user. What is the logic behind this (Python, Tkinter)? How do I make the progress bar appear on the screen while processing is taking place?
To update the progress bar, associate a tkinter variable in it:
import tkinter as t
from tkinter import ttk
root = t.Tk()
.... # codigo definindo o resto da interface ...
var_barra = t.DoubleVar()
minha_barra = ttk.Progressbar(root, variable=var_barra, maximum=30)
Then just update this variable from time to time, and call root.update()
to update on the screen!
var_barra.set(k) # k é um número entre 0 e o máximo
# (definido como 30 no exemplo acima)
root.update()
Time and right way to call these functions depends on the processing you are doing! In general, you can use root.after()
to call a function multiple times automatically.