1 # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
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.py": 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
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.
23 balloon
= DemoBalloon(root
)
28 def __init__(self
, w
):
32 z
= w
.winfo_toplevel()
33 z
.wm_protocol("WM_DELETE_WINDOW", lambda self
=self
: self
.quitcmd())
35 status
= Tix
.Label(w
, width
=40, relief
=Tix
.SUNKEN
, bd
=1)
36 status
.pack(side
=Tix
.BOTTOM
, fill
=Tix
.Y
, padx
=2, pady
=1)
38 # Create two mysterious widgets that need balloon help
39 button1
= Tix
.Button(w
, text
='Something Unexpected',
41 button2
= Tix
.Button(w
, text
='Something Else Unexpected')
42 button2
['command'] = lambda w
=button2
: w
.destroy()
43 button1
.pack(side
=Tix
.TOP
, expand
=1)
44 button2
.pack(side
=Tix
.TOP
, expand
=1)
46 # Create the balloon widget and associate it with the widgets that we want
47 # to provide tips for:
48 b
= Tix
.Balloon(w
, statusbar
=status
)
50 b
.bind_widget(button1
, balloonmsg
='Close Window',
51 statusmsg
='Press this button to close this window')
52 b
.bind_widget(button2
, balloonmsg
='Self-destruct button',
53 statusmsg
='Press this button and it will destroy itself')
60 while self
.exit
< 0 and foundEvent
> 0:
61 foundEvent
= self
.root
.tk
.dooneevent(TCL_ALL_EVENTS
)
66 if __name__
== '__main__':