home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Demo / stdwin / TestSched.py < prev    next >
Text File  |  1996-11-27  |  764b  |  39 lines

  1. #! /usr/bin/env python
  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):
  11.     child.my_id = None
  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 = \
  19.         WindowSched.enter(child.my_number*1000, 0, my_ringer, (child,))
  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)
  39.