Win10 Python3.83
I hope that after clicking button, the corresponding message will pop up, but when this program runs, it is found that a message will be issued when the button is created, but there will be no message when clicked.How to solve it.
import tkinter as tk
import tkinter.messagebox as msg
def cbClicked(cbname):
print(cbname)
msg.showinfo('click', cbname)
cb_list = ['cmd1', 'cmd2', 'cmd3']
win = tk.Tk()
for inx, cbname in enumerate(cb_list):
tk.Button(win, width=10, height=1, text=cbname, command = cbClicked(cbname)).grid(row=0, column=inx)
win.mainloop()