Merged release21-maint changes.
[python/dscho.git] / Demo / tix / samples / Balloon.py
blobdf90660a456eb367cc4f4b146c9ea5173bc48924
1 #!/usr/local/bin/python
2 #
3 # $Id$
5 # Tix Demostration Program
7 # This sample program is structured in such a way so that it can be
8 # executed from the Tix demo program "tixwidgets": it must have a
9 # procedure called "RunSample". It should also have the "if" statment
10 # at the end of this file so that it can be run as a standalone
11 # program.
13 # This file demonstrates the use of the tixBalloon widget, which provides
14 # a interesting way to give help tips about elements in your user interface.
15 # Your can display the help message in a "balloon" and a status bar widget.
18 import Tix
20 def RunSample(w):
21 status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1)
22 status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1)
24 # Create two mysterious widgets that need balloon help
25 button1 = Tix.Button(w, text='Something Unexpected',
26 command=lambda w=w: w.destroy())
27 button2 = Tix.Button(w, text='Something Else Unexpected')
28 button2['command'] = lambda w=button2: w.destroy()
29 button1.pack(side=Tix.TOP, expand=1)
30 button2.pack(side=Tix.TOP, expand=1)
32 # Create the balloon widget and associate it with the widgets that we want
33 # to provide tips for:
34 b = Tix.Balloon(w, statusbar=status)
36 b.bind_widget(button1, balloonmsg='Close Window',
37 statusmsg='Press this button to close this window')
38 b.bind_widget(button2, balloonmsg='Self-destruct button',
39 statusmsg='Press this button and it will destroy itself')
41 if __name__ == '__main__':
42 root = Tix.Tk()
44 RunSample(root)
45 root.mainloop()