-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·32 lines (25 loc) · 921 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
import tkinter as tk
def_font=[ "DejaVuSansMono",100, "normal" ]
def_font2=[ "DejaVuSansMono", 50, "normal" ]
class ExampleApp(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.label = tk.Label(self, text="", width=10, font=def_font)
tk.Label(self, text="Hit ESC to stop", font=def_font2).pack()
self.label.pack()
self.remaining = 0
self.countdown(10)
def countdown(self, remaining = None):
if remaining is not None:
self.remaining = remaining
if self.remaining <= 0:
self.label.configure(text="time's up!")
else:
self.label.configure(text="%d" % self.remaining)
self.remaining = self.remaining - 1
self.after(1000, self.countdown)
if __name__ == "__main__":
app = ExampleApp()
app.bind('<Key-Escape>', lambda event: quit())
app.mainloop()