Guido van Rossum | f06ee5f | 1996-11-27 19:52:01 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
Guido van Rossum | 9cf8f33 | 1992-03-30 10:54:51 +0000 | [diff] [blame] | 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): |
Guido van Rossum | 0e71dc1 | 1992-12-14 14:10:36 +0000 | [diff] [blame] | 11 | child.my_id = None |
Guido van Rossum | 9cf8f33 | 1992-03-30 10:54:51 +0000 | [diff] [blame] | 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 = \ |
Guido van Rossum | 0e71dc1 | 1992-12-14 14:10:36 +0000 | [diff] [blame] | 19 | WindowSched.enter(child.my_number*1000, 0, my_ringer, (child,)) |
Guido van Rossum | 9cf8f33 | 1992-03-30 10:54:51 +0000 | [diff] [blame] | 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) |