第二次倒计时奇怪的行为

时间:2016-02-16 23:53:31

标签: python tkinter

第一次玩游戏时,计时器正常工作,第二次玩游戏时,计时器计数为2?

   def main():
       win1 = Tk()
       win1x = 750
       win1y = 720
       gui1 = MakeGUI(win1,win1x,win1y,"light blue")

       def countdown1(remaining,win):
           if gui1.gameTimer > 0:
               gui1.gameTimer-= 1
               win1.after(1000,countdown1,remaining,win1)
           else:
            pass

       while (gui1.quitGame == False):
           while gui1.startGame == True:
               # start the timer
               countdown1(gui1.gameTimer,win1)
               # start a loop until time up
               while(gui1.gameTimer > 0):
                   gui1.drawGUI()
               gui1.cleanupGUI()
           gui1.initializeGUI()

   main()

1 个答案:

答案 0 :(得分:-1)

在其中一个类文件中发现了该问题。很高兴。