| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
import Tix |
| 17 |
|
| 18 |
options = {'text':'Plain Text', 'post':'PostScript', 'html':'HTML', |
| 19 |
'tex':'LaTeX', 'rtf':'Rich Text Format'} |
| 20 |
|
| 21 |
def RunSample(w): |
| 22 |
global demo_opt_from, demo_opt_to |
| 23 |
|
| 24 |
demo_opt_from = Tix.StringVar() |
| 25 |
demo_opt_to = Tix.StringVar() |
| 26 |
|
| 27 |
top = Tix.Frame(w, bd=1, relief=Tix.RAISED) |
| 28 |
|
| 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') |
| 32 |
|
| 33 |
to_file = Tix.OptionMenu(top, label="To File Format : ", |
| 34 |
variable=demo_opt_to, |
| 35 |
options='label.width 19 label.anchor e menubutton.width 15') |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
for opt in options.keys(): |
| 44 |
from_file.add_command(opt, label=options[opt]) |
| 45 |
to_file.add_command(opt, label=options[opt]) |
| 46 |
|
| 47 |
demo_opt_from.set('html') |
| 48 |
demo_opt_to.set('post') |
| 49 |
|
| 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) |
| 52 |
|
| 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) |
| 60 |
|
| 61 |
def ok_command(w): |
| 62 |
|
| 63 |
w.destroy() |
| 64 |
|
| 65 |
if __name__ == '__main__': |
| 66 |
root = Tix.Tk() |
| 67 |
RunSample(root) |
| 68 |
root.mainloop() |