Just van Rossum | a840fca | 1999-09-26 12:25:06 +0000 | [diff] [blame] | 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: |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 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!" |
Just van Rossum | a840fca | 1999-09-26 12:25:06 +0000 | [diff] [blame] | 20 | |
| 21 | ad = ActivateDemo() |