I have tkinter_sandbox.py
:
from tkinter import *
from tkinter import ttk
root = Tk()
root.title("Tkinter bug?")
mainframe = ttk.Frame(root)
mainframe.grid(column=0, row=0)
buttons = []
for i in range(3):
buttons.append(ttk.Button(mainframe, text="1", command=lambda:print(i)))
buttons[i].grid(row=1, column=i+1)
root.mainloop()
Then, I execute the code using python tkinter_sandbox.py
on cmd. A window pops up, and I click on the buttons from left to right once.
The output on the console is 2 2 2
, whereas 0 1 2
is expected.
Specs:
- Python 3.5.1
- Tkinter version 8.6
- Windows 7 Enterprise