May-12-2018, 05:13 AM
Hi there, i have a problem, I hope you can help me, my problem:
I'm gridding some buttons with for, then i add a value and some command to do, but when i do the command, always give me the last value, the code:
I'm gridding some buttons with for, then i add a value and some command to do, but when i do the command, always give me the last value, the code:
from tkinter import * import tkinter as tk def write_slogan(v): print(v) root = tk.Tk() frame = tk.Frame(root) frame.pack() for k in range(0,11,1): btn = tk.Button(frame, text=str(k), command=lambda: write_slogan(k)) btn.pack(side=tk.LEFT) root.mainloop()What i'm doing wrong?