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 tixOptionMenu widget -- you can
14 # use it for the user to choose from a fixed set of options
18 options
= {'text':'Plain Text', 'post':'PostScript', 'html':'HTML',
19 'tex':'LaTeX', 'rtf':'Rich Text Format'}
22 global demo_opt_from
, demo_opt_to
24 demo_opt_from
= Tix
.StringVar()
25 demo_opt_to
= Tix
.StringVar()
27 top
= Tix
.Frame(w
, bd
=1, relief
=Tix
.RAISED
)
29 from_file
= Tix
.OptionMenu(top
, label
="From File Format : ",
30 variable
=demo_opt_from
,
31 options
= 'label.width 19 label.anchor e menubutton.width 15')
33 to_file
= Tix
.OptionMenu(top
, label
="To File Format : ",
35 options
='label.width 19 label.anchor e menubutton.width 15')
37 # Add the available options to the two OptionMenu widgets
39 # [Hint] You have to add the options first before you set the
40 # global variables "demo_opt_from" and "demo_opt_to". Otherwise
41 # the OptionMenu widget will complain about "unknown options"!
43 for opt
in options
.keys():
44 from_file
.add_command(opt
, label
=options
[opt
])
45 to_file
.add_command(opt
, label
=options
[opt
])
47 demo_opt_from
.set('html')
48 demo_opt_to
.set('post')
50 from_file
.pack(side
=Tix
.TOP
, anchor
=Tix
.W
, pady
=3, padx
=6)
51 to_file
.pack(side
=Tix
.TOP
, anchor
=Tix
.W
, pady
=3, padx
=6)
53 box
= Tix
.ButtonBox(w
, orientation
=Tix
.HORIZONTAL
)
54 box
.add('ok', text
='Ok', underline
=0, width
=6,
55 command
=lambda w
=w
: ok_command(w
))
56 box
.add('cancel', text
='Cancel', underline
=0, width
=6,
57 command
=lambda w
=w
: w
.destroy())
58 box
.pack(side
=Tix
.BOTTOM
, fill
=Tix
.X
)
59 top
.pack(side
=Tix
.TOP
, fill
=Tix
.BOTH
, expand
=1)
62 # tixDemo:Status "Convert file from %s to %s" % ( demo_opt_from.get(), demo_opt_to.get())
65 if __name__
== '__main__':