Expand|Select|Wrap|Line Numbers
- from Tkinter import*
- import random
- import time
- number = 5
- i = 0
- class Test():
- def __init__(self):
- i=0
- self.root = Tk()
- self.root.title('Test')
- self.can = Canvas(self.root, width= 800, height = 600, bg='Blue')
- self.can.grid()
- self.b = Button(self.root, width=25, height = 5, text="START TEST", command=self.countdown)
- self.b.grid(column=0, row=0)
- self.root.mainloop()
- def countdown(self):
- global i
- global number
- if i == 0:
- self.b.destroy()
- self.text=self.can.create_text(400, 300, text='TEST STARTS IN...')
- i+=1
- self.countdown()
- elif i>0 and i<6:
- self.text=self.can.create_text(400, 325, text=number)
- time.sleep(1)
- self.text.delete()
- self.root.update()
- number=number-1
- self.countdown()
- else:
- pass
- Test()