home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2505 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.7 KB  |  50 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import timer
  5. import time
  6. import win32event
  7. import win32gui
  8.  
  9. class glork:
  10.     
  11.     def __init__(self, delay = 1000, max = 10):
  12.         self.x = 0
  13.         self.max = max
  14.         self.id = timer.set_timer(delay, self.increment)
  15.         self.event = win32event.CreateEvent(None, 0, 0, None)
  16.  
  17.     
  18.     def increment(self, id, time):
  19.         print 'x = %d' % self.x
  20.         self.x = self.x + 1
  21.         if self.x > self.max:
  22.             timer.kill_timer(id)
  23.             win32event.SetEvent(self.event)
  24.         
  25.  
  26.  
  27.  
  28. def demo(delay = 1000, stop = 10):
  29.     g = glork(delay, stop)
  30.     start_time = time.time()
  31.     while None:
  32.         rc = win32event.MsgWaitForMultipleObjects((g.event,), 0, 500, win32event.QS_ALLEVENTS)
  33.         if rc == win32event.WAIT_OBJECT_0:
  34.             break
  35.             continue
  36.         if rc == win32event.WAIT_OBJECT_0 + 1:
  37.             if win32gui.PumpWaitingMessages():
  38.                 raise RuntimeError, 'We got an unexpected WM_QUIT message!'
  39.             win32gui.PumpWaitingMessages()
  40.             continue
  41.         if time.time() - start_time > 30:
  42.             raise RuntimeError, 'We timed out waiting for the timers to expire!'
  43.         time.time() - start_time > 30
  44.         continue
  45.         return None
  46.  
  47. if __name__ == '__main__':
  48.     demo()
  49.  
  50.