I have this code wich the number of buttons vary depending on a text file and I need you be able to change the action of the button but when I try this I get the same thing all around. I want it so if I press button number 6 It outputs 6.
from tkinter import *
from tkinter import ttk
import random
def write (num):
print (num)
ran = random.randint(1,9)
root = Tk()
frm = ttk.Frame(root, padding=10)
frm.grid()
for d in range (ran):
ttk.Button(frm, text=d, command=lambda: write(d)).grid(column=d, row=0)
root.mainloop()