De base de la minuterie dans tkinter

J'ai écrit un code pour un python minuterie, mais quand je le lance j'ai une erreur mais le truc c'est que je ne sais pas quoi faire alors je suis venu ici pour obtenir de l'aide après que j'ai cherché partout sur internet pour de l'aide mais je n'ai rien trouvé qui correspondait à mon problème.

Voici l'Erreur:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\Python33\lib\tkinter\__init__.py", line 1475, in __call__
    return self.func(*args)
  File "C:\Users\Public\Documents\Programming\Timer.py", line 27, in start
    sec = sec + 1
UnboundLocalError: local variable 'sec' referenced before assignment

C'est mon code:

# Import Modules
from tkinter import *
import time

# Window Setup
root = Tk()
root.title('Timer')
root.state('zoomed')

# Timer Variables
global sec
time_sec = StringVar()
sec = 0

# Timer Start
def start():
    while 1:
        time.sleep(1)
        sec = sec + 1
        time_sec.set(sec)
        start()

# Timer Setup
Label(root,
      textvariable=time_sec,
      fg='green').pack()
Button(root,
       fg='blue',
       text='Start',
       command=start).pack()

# Program Loop
root.mainloop()

Quelqu'un pourrait-il m'aider?

Merci D'Avance!

InformationsquelleAutor Arctoran | 2013-07-13