0
我試圖解除/禁用鍵一旦點擊,並恢復其功能後2s。但我無法弄清楚解除綁定的代碼。綁定在窗口上。這裏是我到目前爲止的代碼:蟒蛇解除綁定/禁用鍵綁定後點擊並稍後恢復它
self.choiceA = self.master.bind('a', self.run1) #bind key "a" to run1
def run1(self, event=None):
self.draw_confirmation_button1()
self.master.unbind('a', self.choiceA) #try1: use "unbind", doesn't work
self.choiceA.configure(state='disabled') #try2: use state='disabled', doesn't't work, I assume it only works for button
self.master.after(2000, lambda:self.choiceA.configure(state="normal"))
此外,如何在2秒後重新啓用密鑰?
非常感謝!