![](/img/trans.png)
[英]How can you make 3 (or 4) nested binded comboxes uting Tkinter in python?
[英]How to make one binded key execute two commands in tkinter, python?
所以我想做的是讓我的 tkinter window 在按下回車鍵后關閉,但同時使用回車執行給定的命令
newWindow.bind("<Return>", ui_add)
newWindow.bind("<Return>", newWindow.destroy)
我希望 Return 鍵執行 function ui_add 和 AFTER 使 window 關閉。 它只是關閉 window 並且不執行第一個命令。
最簡單的解決方案是創建一個新的 function。 還有其他方法,但這是最容易調試和維護的方法。
def callback(event):
ui_add(event)
new_window.destroy()
newWindow.bind(‘<Return>’, callback)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.