home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Mac / IDE scripts / Widget demos / ActivateWindowDemo.py next >
Encoding:
Python Source  |  2000-06-23  |  574 b   |  22 lines

  1. import W
  2.  
  3. # this demoscript illustrates how to tie a callback to activating or clicking away of the window.
  4. # evb 22 4 99
  5.  
  6. class ActivateDemo:
  7.     
  8.     def __init__(self):
  9.         self.w = W.Window((200, 200), 'Activate demo')
  10.         self.w.bind("<activate>", self.my_activate_callback)
  11.         self.w.open()
  12.     
  13.     def my_activate_callback(self, onoff):
  14.         '''the callback gets 1 parameter which indicates whether the window
  15.         has been activated (1) or clicked to the back (0)'''
  16.         if onoff == 1:
  17.             print "I'm in the front now!"
  18.         else:
  19.             print "I've been clicked away, Oh No!"
  20.  
  21. ad = ActivateDemo()
  22.