[問題] tkinter搭配timer按下alt鍵會被暫停

作者: flow142857 (flow)   2021-03-30 15:21:41
程式如下 :
import tkinter as tk
import time, threading
def update_label():
global label_obj
now_time = int(time.time())
msg_text = "%d" % (now_time)
label_obj.configure(text = msg_text)
print("time", msg_text)
def start_timer():
global timer_obj
update_label()
timer_obj = threading.Timer(1, start_timer)
timer_obj.setDaemon(True)
timer_obj.start()
root_obj = tk.Tk()
label_obj = tk.Label(root_obj)
label_obj.grid(row = 0, column = 0)
start_timer()
root_obj.update()
root_obj.mainloop()
問題 :
視窗會持續顯示目前的時間, console 也會印出目前的時間, 但是如果按了 Alt 鍵
(按下再放開), 視窗和 console 都會暫停不繼續更新, 除非隨便按個按鍵或是滑鼠
隨便點一下才會恢復, 請問有辦法消除這個問題嗎, 謝謝.
作者: Whisky (AnAn Ni Hao)   2021-03-31 17:05:00
作者: flow142857 (flow)   2021-04-01 11:13:00
懂了,謝謝

Links booklink

Contact Us: admin [ a t ] ucptt.com