Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Created March 20, 2024 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vigilantPotato/f67afec1bd96755db7c6d9dd9a1724eb to your computer and use it in GitHub Desktop.
Save vigilantPotato/f67afec1bd96755db7c6d9dd9a1724eb to your computer and use it in GitHub Desktop.
button click counter
import ctypes
import tkinter
def count_up(): #count-up function
if var.get() == 10:
var.set(0)
else:
var.set(var.get() + 1) #count up
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
var = tkinter.IntVar(root) #variable for counter
#label
l = tkinter.Label(
root,
textvariable=var,
)
l.pack()
#count-up button
b = tkinter.Button(
root,
text="Count Button",
width=15,
command=count_up,
)
b.pack()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment