#!/usr/bin/env python import Tkinter class myWindow: def __init__(self): self.mw = Tkinter.Tk() self.mw.option_add("*font", ("Arial", 15, "normal")) self.mw.title("Time-Limit") self.mw.geometry("+250+250") self.t = 20 self.password = "Swordfish" self.entered = None self.lab1 = Tkinter.Label(self.mw, text = str(self.t)) self.lab1.pack(padx = 20, pady = 20) self.fr1 = Tkinter.Frame() self.lab2 = Tkinter.Label(self.fr1, text = "Enter Password:") self.lab2.pack(anchor = Tkinter.W) self.entry1 = Tkinter.Entry(self.fr1, bg = 'white') self.entry1.pack() self.entry1.focus() self.entry1.bind("", self.checkPass) self.fr1.pack(padx = 10, pady = 10) self.mw.after(1000, self.countdown) self.mw.mainloop() def countdown(self): if self.entered == self.password: return self.t -= 1 if self.t > 0: self.lab1.configure(text = str(self.t)) self.mw.after(1000, self.countdown) else: self.lab1.configure(text = "Verloren!") def checkPass(self, ev): if self.t <= 0: self.lab1.configure(text = "Too Late!") return self.entered = self.entry1.get() if self.entered == self.password: self.entry1.delete(0, Tkinter.END) self.lab1.configure(text = "Gewonnen!") if __name__ == "__main__": app = myWindow()