Skip to content

Instantly share code, notes, and snippets.

@Franck1333
Last active October 16, 2018 15:05
Show Gist options
  • Select an option

  • Save Franck1333/87f0b3095bf4de5ccb1fb5ed42b9aed0 to your computer and use it in GitHub Desktop.

Select an option

Save Franck1333/87f0b3095bf4de5ccb1fb5ed42b9aed0 to your computer and use it in GitHub Desktop.
Get Dynamic Label , ProgressBar or any content be dynamic with this examples on TKINTER
#AIDES: https://stackoverflow.com/questions/18047636/python-is-it-possible-to-create-an-tkinter-label-which-has-a-dynamic-string-whe
import tkinter as tk
root = tk.Tk()
status = tk.Label(root, text="Working")
status.grid()
def update_status():
# Get the current message
current_status = status["text"]
# If the message is "Working...", start over with "Working"
if current_status.endswith("..."): current_status = "Working"
# If not, then just add a "." on the end
else: current_status += "."
# Update the message
status["text"] = current_status
# After 1 second, update the status
root.after(1000, update_status)
# Launch the status message after 1 millisecond (when the window is loaded)
root.after(1, update_status)
root.mainloop()
#AIDES: https://stackoverflow.com/questions/18047636/python-is-it-possible-to-create-an-tkinter-label-which-has-a-dynamic-string-whe
import tkinter as tk
# You will need the ttk module for this
from tkinter import ttk
def update_status(step):
# Step here is how much to increment the progressbar by.
# It is in relation to the progressbar's length.
# Since I made the length 100 and I am increasing by 10 each time,
# there will be 10 times it increases before it restarts
progress.step(step)
# You can call 'update_status' whenever you want in your script
# to increase the progressbar by whatever amount you want.
root.after(1000, lambda: update_status(10))
root = tk.Tk()
progress = ttk.Progressbar(root, length=100)
progress.pack()
progress.after(1, lambda: update_status(10))
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment