小编Luc*_*s N的帖子

Python tkinter time.sleep()

为什么我运行我的代码,它会先睡3秒,然后执行'label'.lift()并更改文本?这只是该计划中许多人的一项功能.我希望标签上写着"从3 ... 2 ...... 1开始...",当第二个过去时,数字会改变.

def predraw(self):
    self.lost=False
    self.lossmessage.lower()
    self.countdown.lift()
    self.dx=20
    self.dy=0
    self.delay=200
    self.x=300
    self.y=300
    self.foodx=self.list[random.randint(0,29)]
    self.foody=self.list[random.randint(0,29)]
    self.fillcol='blue'
    self.canvas['bg']='white'
    self.lossmessage['text']='You lost! :('
    self.score['text']=0
    self.countdown['text']='Starting in...3'
    time.sleep(1)
    self.countdown['text']='Starting in...2'
    time.sleep(1)
    self.countdown['text']='Starting in...1'
    time.sleep(1)
    self.countdown.lower()
    self.drawsnake()
Run Code Online (Sandbox Code Playgroud)

python sleep tkinter

1
推荐指数
1
解决办法
643
查看次数

标签 统计

python ×1

sleep ×1

tkinter ×1