[問題] Tkinter中Button按下的function啟動時機

看板Python作者 (gg)時間8年前 (2018/01/07 16:57), 8年前編輯推噓1(104)
留言5則, 3人參與, 8年前最新討論串1/1
首次發文不清楚請包涵 我在使用button時,當中command放了一個click()的function並有正確放def click()在button之前,但執行時我沒按button就直接執行click的指令了欸? ----- Sent from JPTT on my Sony D6653. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 39.8.164.6 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1515315431.A.AAC.html ※ 編輯: GlassesKJ (39.8.164.6), 01/07/2018 16:58:49 ※ 編輯: GlassesKJ (39.8.164.6), 01/07/2018 17:00:05

01/07 17:36, 8年前 , 1F
用lambda的方式呼叫click listener
01/07 17:36, 1F

01/07 17:42, 8年前 , 2F
command=self.click
01/07 17:42, 2F

01/07 17:43, 8年前 , 3F
不要加()
01/07 17:43, 3F

01/07 18:05, 8年前 , 4F
欸真的改成command=click()就可以了
01/07 18:05, 4F

01/07 18:06, 8年前 , 5F
*改成command=click
01/07 18:06, 5F
文章代碼(AID): #1QKU3dgi (Python)