Mercurial > cpython-lru_cache-weakref
annotate Demo/stdwin/TestSched.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 73758db2f464 |
| children |
| rev | line source |
|---|---|
|
4573
73758db2f464
/usr/local/bin/python -> /usr/bin/env python
Guido van Rossum <guido@python.org>
parents:
1117
diff
changeset
|
1 #! /usr/bin/env python |
| 752 | 2 |
| 3 # TestSched | |
| 4 | |
| 5 import stdwin | |
| 6 from WindowParent import WindowParent, MainLoop | |
| 7 import WindowSched | |
| 8 from Buttons import PushButton | |
| 9 | |
| 10 def my_ringer(child): | |
|
1117
1a0be6e36818
Adapted to modern times and fixed a bug (id --> my_id)
Guido van Rossum <guido@python.org>
parents:
752
diff
changeset
|
11 child.my_id = None |
| 752 | 12 stdwin.fleep() |
| 13 | |
| 14 def my_hook(child): | |
| 15 # schedule for the bell to ring in N seconds; cancel previous | |
| 16 if child.my_id: | |
| 17 WindowSched.cancel(child.my_id) | |
| 18 child.my_id = \ | |
|
1117
1a0be6e36818
Adapted to modern times and fixed a bug (id --> my_id)
Guido van Rossum <guido@python.org>
parents:
752
diff
changeset
|
19 WindowSched.enter(child.my_number*1000, 0, my_ringer, (child,)) |
| 752 | 20 |
| 21 def main(n): | |
| 22 from CSplit import CSplit | |
| 23 | |
| 24 window = WindowParent().create('TestSched', (0, 0)) | |
| 25 csplit = CSplit().create(window) | |
| 26 | |
| 27 for i in range(n): | |
| 28 child = PushButton().define(csplit) | |
| 29 child.my_number = i | |
| 30 child.my_id = None | |
| 31 child.settext(`(i+n-1)%n+1`) | |
| 32 child.hook = my_hook | |
| 33 | |
| 34 window.realize() | |
| 35 | |
| 36 WindowSched.run() | |
| 37 | |
| 38 main(12) |
