Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1 | #!/usr/local/bin/python |
| 2 | # |
| 3 | # $Id$ |
| 4 | # |
| 5 | # Tix Demostration Program |
| 6 | # |
| 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. |
| 12 | |
| 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. |
| 16 | # |
| 17 | |
| 18 | import Tix |
| 19 | |
| 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) |
| 23 | |
| 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) |
| 31 | |
| 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) |
| 35 | |
| 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') |
| 40 | |
| 41 | if __name__ == '__main__': |
| 42 | root = Tix.Tk() |
| 43 | |
| 44 | RunSample(root) |
| 45 | root.mainloop() |