我有一个名为 _their_grid 的画布,它有许多与鼠标点击相关的相关事件。我在特定条件下禁用它 10 秒。下面是相关代码。
print "not your turn"
# disable opponent's grid during their turn
self._their_grid.config(state=DISABLED)
time.sleep(10)
self._their_grid.config(state=NORMAL)
print "now you can go"
然而,在十秒钟的睡眠中,我仍然设法触发了这些事件。这不应该是这种情况,因为 state=DISABLED 应该关闭所有事件。下面的代码,注释掉了 sleep,停止了所有事件。
print "not your turn"
# disable opponent's grid during their turn
self._their_grid.config(state=DISABLED)
#time.sleep(10)
#self._their_grid.config(state=NORMAL)
#print "now you can go"
为什么我会在 time.sleep 中出现这种奇怪的行为?