Hi have this loop but insted of send the correct value in the button it always send the original value
this creates the buttons named from 0 to 9, but when i run the button it always prints 8 insted of 8,9,10 etc...
from tkinter import *
from tkinter import ttk
root = Tk()
global gen_reprow,x
gen_reprow=8
x=0
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
def printd(gena):
print(gena)
def ger_but():
for x in range(10):
ttk.Button(mainframe, width="15", text=x,command=lambda gen=gen_reprow: printd(gen)).grid(column=0, row=x, padx=1, pady=15)
x += 1
gen_reprow += 1
ger_but()
if __name__ == "__main__":
root.mainloop()