The grid
, pack
, and place
methods of every Tkinter widget operate in-place and always return None
. This means that you cannot call them on the same line as you create a widget. Instead, they should be called on the line below:
widget = ...
widget.grid(...)
widget = ...
widget.pack(...)
widget = ...
widget.place(...)
So, in your code, it would be:
b[c+(r*10)] = Button(f, text=chr(97+c+(r*10)), command=lambda a=c+(r*10): color(a), borderwidth=1,width=5,bg="white")
b[c+(r*10)].grid(row=r,column=c)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…