Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Last active March 7, 2024 21:05
Show Gist options
  • Save vigilantPotato/57170f24154fbbb181dfc889d8b6bea5 to your computer and use it in GitHub Desktop.
Save vigilantPotato/57170f24154fbbb181dfc889d8b6bea5 to your computer and use it in GitHub Desktop.
how to use progressbar (determinate)
import ctypes
import tkinter
from tkinter import ttk
#button function
def count_up():
if var.get() < 100:
var.set(var.get() + 10)
else:
var.set(0)
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
#variable for counter
var = tkinter.IntVar(root)
#Progressbar(determinate)
pb = ttk.Progressbar(
root,
maximum=100, #maximum
mode="determinate", #determinate mode
variable=var, #counter
orient="horizontal",#orient
)
pb.pack()
#countup button
cb = tkinter.Button(
root,
text="count up",
command=count_up,
)
cb.pack()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment