[問題] tkinter command 傳參數問題

看板Python作者 (霧峰小霸王)時間14年前 (2012/01/19 16:56), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/2 (看更多)
for i in range(0,3): g[i]=tk.Button(sf,text = '按鈕',command=lambda:myfunction(i)) g[i].grid(row=row_num,column=3) 為什麼在myfunction接收參數時都是2 是我寫錯那裡嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.170.18.107

01/19 22:52, , 1F
command=lambda i=i:myfunction(i)
01/19 22:52, 1F

01/20 09:40, , 2F
謝謝!!剛試過可以了!
01/20 09:40, 2F
文章代碼(AID): #1F5zgcLa (Python)
討論串 (同標題文章)
文章代碼(AID): #1F5zgcLa (Python)