New course! Every coder should learn Generative AI!
Try a free lesson+ 5
import tkinter as tk
from tkinter import ttk
win = tk.Tk()
win.geometry('300x300')
def count():
n = 1
while True:
yield str(n)
n += 1
c = count()
btn = tk.Button(win, text = '0', command = lambda: btn.config(text = next(c)))
btn.pack()
win.mainloop()