[英]Is there a way of opening an external .exe which doesn't pause the rest of the program? python
[英]Python timer that doesn't pause the whole program
我正在嘗試為一個簡單的游戲制作一個模式,您可以在其中使用 tkinter 在物品掉落時抓住它們。
在這種模式下,您有 60 秒的時間捕捉盡可能多的物品。 我嘗試過的所有計時器方法都會暫停整個程序
...嘗試使用空的 label,但.after 暫停了整個程序
timerlabel = tkinter.Label(text="")
def timer():
global t, timerdisplay
while t > 0:
t -= 1
timerlabel.after(1000)
c.delete(timerdisplay)
timerdisplay = c.create_text(200, 12, text=t)
c.update()
知道怎么做嗎?
這是更好的方法,特別是因為after(n)
在給定的時間段內凍結程序。 創建一個接受數字並顯示該數字的 function。 然后,它減一,然后重新安排自己在未來運行一秒鍾,直到數字變為零。
def timer(t):
global timerdisplay
c.delete(timerdisplay)
timerdisplay = c.create_text(200, 12, text=t)
if t >= 1:
c.after(1000, timer, t-1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.