Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2..../Demo/tix
File: tixwidgets.py
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
[0] Fix | Delete
#
[1] Fix | Delete
# $Id$
[2] Fix | Delete
#
[3] Fix | Delete
# tixwidgets.py --
[4] Fix | Delete
#
[5] Fix | Delete
# For Tix, see http://tix.sourceforge.net
[6] Fix | Delete
#
[7] Fix | Delete
# This is a demo program of some of the Tix widgets available in Python.
[8] Fix | Delete
# If you have installed Python & Tix properly, you can execute this as
[9] Fix | Delete
#
[10] Fix | Delete
# % python tixwidgets.py
[11] Fix | Delete
#
[12] Fix | Delete
[13] Fix | Delete
import os, os.path, sys, Tix
[14] Fix | Delete
from Tkconstants import *
[15] Fix | Delete
import traceback, tkMessageBox
[16] Fix | Delete
[17] Fix | Delete
TCL_DONT_WAIT = 1<<1
[18] Fix | Delete
TCL_WINDOW_EVENTS = 1<<2
[19] Fix | Delete
TCL_FILE_EVENTS = 1<<3
[20] Fix | Delete
TCL_TIMER_EVENTS = 1<<4
[21] Fix | Delete
TCL_IDLE_EVENTS = 1<<5
[22] Fix | Delete
TCL_ALL_EVENTS = 0
[23] Fix | Delete
[24] Fix | Delete
class Demo:
[25] Fix | Delete
def __init__(self, top):
[26] Fix | Delete
self.root = top
[27] Fix | Delete
self.exit = -1
[28] Fix | Delete
[29] Fix | Delete
self.dir = None # script directory
[30] Fix | Delete
self.balloon = None # balloon widget
[31] Fix | Delete
self.useBalloons = Tix.StringVar()
[32] Fix | Delete
self.useBalloons.set('0')
[33] Fix | Delete
self.statusbar = None # status bar widget
[34] Fix | Delete
self.welmsg = None # Msg widget
[35] Fix | Delete
self.welfont = '' # font name
[36] Fix | Delete
self.welsize = '' # font size
[37] Fix | Delete
[38] Fix | Delete
progname = sys.argv[0]
[39] Fix | Delete
dirname = os.path.dirname(progname)
[40] Fix | Delete
if dirname and dirname != os.curdir:
[41] Fix | Delete
self.dir = dirname
[42] Fix | Delete
index = -1
[43] Fix | Delete
for i in range(len(sys.path)):
[44] Fix | Delete
p = sys.path[i]
[45] Fix | Delete
if p in ("", os.curdir):
[46] Fix | Delete
index = i
[47] Fix | Delete
if index >= 0:
[48] Fix | Delete
sys.path[index] = dirname
[49] Fix | Delete
else:
[50] Fix | Delete
sys.path.insert(0, dirname)
[51] Fix | Delete
else:
[52] Fix | Delete
self.dir = os.getcwd()
[53] Fix | Delete
sys.path.insert(0, self.dir+'/samples')
[54] Fix | Delete
[55] Fix | Delete
def MkMainMenu(self):
[56] Fix | Delete
top = self.root
[57] Fix | Delete
w = Tix.Frame(top, bd=2, relief=RAISED)
[58] Fix | Delete
file = Tix.Menubutton(w, text='File', underline=0, takefocus=0)
[59] Fix | Delete
help = Tix.Menubutton(w, text='Help', underline=0, takefocus=0)
[60] Fix | Delete
file.pack(side=LEFT)
[61] Fix | Delete
help.pack(side=RIGHT)
[62] Fix | Delete
fm = Tix.Menu(file, tearoff=0)
[63] Fix | Delete
file['menu'] = fm
[64] Fix | Delete
hm = Tix.Menu(help, tearoff=0)
[65] Fix | Delete
help['menu'] = hm
[66] Fix | Delete
[67] Fix | Delete
fm.add_command(label='Exit', underline=1,
[68] Fix | Delete
command = lambda self=self: self.quitcmd () )
[69] Fix | Delete
hm.add_checkbutton(label='BalloonHelp', underline=0, command=ToggleHelp,
[70] Fix | Delete
variable=self.useBalloons)
[71] Fix | Delete
# The trace variable option doesn't seem to work, instead I use 'command'
[72] Fix | Delete
#apply(w.tk.call, ('trace', 'variable', self.useBalloons, 'w',
[73] Fix | Delete
# ToggleHelp))
[74] Fix | Delete
[75] Fix | Delete
return w
[76] Fix | Delete
[77] Fix | Delete
def MkMainNotebook(self):
[78] Fix | Delete
top = self.root
[79] Fix | Delete
w = Tix.NoteBook(top, ipadx=5, ipady=5, options="""
[80] Fix | Delete
tagPadX 6
[81] Fix | Delete
tagPadY 4
[82] Fix | Delete
borderWidth 2
[83] Fix | Delete
""")
[84] Fix | Delete
# This may be required if there is no *Background option
[85] Fix | Delete
top['bg'] = w['bg']
[86] Fix | Delete
[87] Fix | Delete
w.add('wel', label='Welcome', underline=0,
[88] Fix | Delete
createcmd=lambda w=w, name='wel': MkWelcome(w, name))
[89] Fix | Delete
w.add('cho', label='Choosers', underline=0,
[90] Fix | Delete
createcmd=lambda w=w, name='cho': MkChoosers(w, name))
[91] Fix | Delete
w.add('scr', label='Scrolled Widgets', underline=0,
[92] Fix | Delete
createcmd=lambda w=w, name='scr': MkScroll(w, name))
[93] Fix | Delete
w.add('mgr', label='Manager Widgets', underline=0,
[94] Fix | Delete
createcmd=lambda w=w, name='mgr': MkManager(w, name))
[95] Fix | Delete
w.add('dir', label='Directory List', underline=0,
[96] Fix | Delete
createcmd=lambda w=w, name='dir': MkDirList(w, name))
[97] Fix | Delete
w.add('exp', label='Run Sample Programs', underline=0,
[98] Fix | Delete
createcmd=lambda w=w, name='exp': MkSample(w, name))
[99] Fix | Delete
return w
[100] Fix | Delete
[101] Fix | Delete
def MkMainStatus(self):
[102] Fix | Delete
global demo
[103] Fix | Delete
top = self.root
[104] Fix | Delete
[105] Fix | Delete
w = Tix.Frame(top, relief=Tix.RAISED, bd=1)
[106] Fix | Delete
demo.statusbar = Tix.Label(w, relief=Tix.SUNKEN, bd=1)
[107] Fix | Delete
demo.statusbar.form(padx=3, pady=3, left=0, right='%70')
[108] Fix | Delete
return w
[109] Fix | Delete
[110] Fix | Delete
def build(self):
[111] Fix | Delete
root = self.root
[112] Fix | Delete
z = root.winfo_toplevel()
[113] Fix | Delete
z.wm_title('Tix Widget Demonstration')
[114] Fix | Delete
if z.winfo_screenwidth() <= 800:
[115] Fix | Delete
z.geometry('790x590+10+10')
[116] Fix | Delete
else:
[117] Fix | Delete
z.geometry('890x640+10+10')
[118] Fix | Delete
demo.balloon = Tix.Balloon(root)
[119] Fix | Delete
frame1 = self.MkMainMenu()
[120] Fix | Delete
frame2 = self.MkMainNotebook()
[121] Fix | Delete
frame3 = self.MkMainStatus()
[122] Fix | Delete
frame1.pack(side=TOP, fill=X)
[123] Fix | Delete
frame3.pack(side=BOTTOM, fill=X)
[124] Fix | Delete
frame2.pack(side=TOP, expand=1, fill=BOTH, padx=4, pady=4)
[125] Fix | Delete
demo.balloon['statusbar'] = demo.statusbar
[126] Fix | Delete
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
[127] Fix | Delete
[128] Fix | Delete
# To show Tcl errors - uncomment this to see the listbox bug.
[129] Fix | Delete
# Tkinter defines a Tcl tkerror procedure that in effect
[130] Fix | Delete
# silences all background Tcl error reporting.
[131] Fix | Delete
# root.tk.eval('if {[info commands tkerror] != ""} {rename tkerror pytkerror}')
[132] Fix | Delete
def quitcmd (self):
[133] Fix | Delete
"""Quit our mainloop. It is up to you to call root.destroy() after."""
[134] Fix | Delete
self.exit = 0
[135] Fix | Delete
[136] Fix | Delete
def loop(self):
[137] Fix | Delete
"""This is an explict replacement for _tkinter mainloop()
[138] Fix | Delete
It lets you catch keyboard interrupts easier, and avoids
[139] Fix | Delete
the 20 msec. dead sleep() which burns a constant CPU."""
[140] Fix | Delete
while self.exit < 0:
[141] Fix | Delete
# There are 2 whiles here. The outer one lets you continue
[142] Fix | Delete
# after a ^C interrupt.
[143] Fix | Delete
try:
[144] Fix | Delete
# This is the replacement for _tkinter mainloop()
[145] Fix | Delete
# It blocks waiting for the next Tcl event using select.
[146] Fix | Delete
while self.exit < 0:
[147] Fix | Delete
self.root.tk.dooneevent(TCL_ALL_EVENTS)
[148] Fix | Delete
except SystemExit:
[149] Fix | Delete
# Tkinter uses SystemExit to exit
[150] Fix | Delete
#print 'Exit'
[151] Fix | Delete
self.exit = 1
[152] Fix | Delete
return
[153] Fix | Delete
except KeyboardInterrupt:
[154] Fix | Delete
if tkMessageBox.askquestion ('Interrupt', 'Really Quit?') == 'yes':
[155] Fix | Delete
# self.tk.eval('exit')
[156] Fix | Delete
self.exit = 1
[157] Fix | Delete
return
[158] Fix | Delete
continue
[159] Fix | Delete
except:
[160] Fix | Delete
# Otherwise it's some other error - be nice and say why
[161] Fix | Delete
t, v, tb = sys.exc_info()
[162] Fix | Delete
text = ""
[163] Fix | Delete
for line in traceback.format_exception(t,v,tb):
[164] Fix | Delete
text += line + '\n'
[165] Fix | Delete
try: tkMessageBox.showerror ('Error', text)
[166] Fix | Delete
except: pass
[167] Fix | Delete
self.exit = 1
[168] Fix | Delete
raise SystemExit, 1
[169] Fix | Delete
[170] Fix | Delete
def destroy (self):
[171] Fix | Delete
self.root.destroy()
[172] Fix | Delete
[173] Fix | Delete
def RunMain(root):
[174] Fix | Delete
global demo
[175] Fix | Delete
[176] Fix | Delete
demo = Demo(root)
[177] Fix | Delete
[178] Fix | Delete
demo.build()
[179] Fix | Delete
demo.loop()
[180] Fix | Delete
demo.destroy()
[181] Fix | Delete
[182] Fix | Delete
# Tabs
[183] Fix | Delete
def MkWelcome(nb, name):
[184] Fix | Delete
w = nb.page(name)
[185] Fix | Delete
bar = MkWelcomeBar(w)
[186] Fix | Delete
text = MkWelcomeText(w)
[187] Fix | Delete
bar.pack(side=TOP, fill=X, padx=2, pady=2)
[188] Fix | Delete
text.pack(side=TOP, fill=BOTH, expand=1)
[189] Fix | Delete
[190] Fix | Delete
def MkWelcomeBar(top):
[191] Fix | Delete
global demo
[192] Fix | Delete
[193] Fix | Delete
w = Tix.Frame(top, bd=2, relief=Tix.GROOVE)
[194] Fix | Delete
b1 = Tix.ComboBox(w, command=lambda w=top: MainTextFont(w))
[195] Fix | Delete
b2 = Tix.ComboBox(w, command=lambda w=top: MainTextFont(w))
[196] Fix | Delete
b1.entry['width'] = 15
[197] Fix | Delete
b1.slistbox.listbox['height'] = 3
[198] Fix | Delete
b2.entry['width'] = 4
[199] Fix | Delete
b2.slistbox.listbox['height'] = 3
[200] Fix | Delete
[201] Fix | Delete
demo.welfont = b1
[202] Fix | Delete
demo.welsize = b2
[203] Fix | Delete
[204] Fix | Delete
b1.insert(Tix.END, 'Courier')
[205] Fix | Delete
b1.insert(Tix.END, 'Helvetica')
[206] Fix | Delete
b1.insert(Tix.END, 'Lucida')
[207] Fix | Delete
b1.insert(Tix.END, 'Times Roman')
[208] Fix | Delete
[209] Fix | Delete
b2.insert(Tix.END, '8')
[210] Fix | Delete
b2.insert(Tix.END, '10')
[211] Fix | Delete
b2.insert(Tix.END, '12')
[212] Fix | Delete
b2.insert(Tix.END, '14')
[213] Fix | Delete
b2.insert(Tix.END, '18')
[214] Fix | Delete
[215] Fix | Delete
b1.pick(1)
[216] Fix | Delete
b2.pick(3)
[217] Fix | Delete
[218] Fix | Delete
b1.pack(side=Tix.LEFT, padx=4, pady=4)
[219] Fix | Delete
b2.pack(side=Tix.LEFT, padx=4, pady=4)
[220] Fix | Delete
[221] Fix | Delete
demo.balloon.bind_widget(b1, msg='Choose\na font',
[222] Fix | Delete
statusmsg='Choose a font for this page')
[223] Fix | Delete
demo.balloon.bind_widget(b2, msg='Point size',
[224] Fix | Delete
statusmsg='Choose the font size for this page')
[225] Fix | Delete
return w
[226] Fix | Delete
[227] Fix | Delete
def MkWelcomeText(top):
[228] Fix | Delete
global demo
[229] Fix | Delete
[230] Fix | Delete
w = Tix.ScrolledWindow(top, scrollbar='auto')
[231] Fix | Delete
win = w.window
[232] Fix | Delete
text = 'Welcome to TIX in Python'
[233] Fix | Delete
title = Tix.Label(win,
[234] Fix | Delete
bd=0, width=30, anchor=Tix.N, text=text)
[235] Fix | Delete
msg = Tix.Message(win,
[236] Fix | Delete
bd=0, width=400, anchor=Tix.N,
[237] Fix | Delete
text='Tix is a set of mega-widgets based on TK. This program \
[238] Fix | Delete
demonstrates the widgets in the Tix widget set. You can choose the pages \
[239] Fix | Delete
in this window to look at the corresponding widgets. \n\n\
[240] Fix | Delete
To quit this program, choose the "File | Exit" command.\n\n\
[241] Fix | Delete
For more information, see http://tix.sourceforge.net.')
[242] Fix | Delete
title.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10)
[243] Fix | Delete
msg.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10)
[244] Fix | Delete
demo.welmsg = msg
[245] Fix | Delete
return w
[246] Fix | Delete
[247] Fix | Delete
def MainTextFont(w):
[248] Fix | Delete
global demo
[249] Fix | Delete
[250] Fix | Delete
if not demo.welmsg:
[251] Fix | Delete
return
[252] Fix | Delete
font = demo.welfont['value']
[253] Fix | Delete
point = demo.welsize['value']
[254] Fix | Delete
if font == 'Times Roman':
[255] Fix | Delete
font = 'times'
[256] Fix | Delete
fontstr = '%s %s' % (font, point)
[257] Fix | Delete
demo.welmsg['font'] = fontstr
[258] Fix | Delete
[259] Fix | Delete
def ToggleHelp():
[260] Fix | Delete
if demo.useBalloons.get() == '1':
[261] Fix | Delete
demo.balloon['state'] = 'both'
[262] Fix | Delete
else:
[263] Fix | Delete
demo.balloon['state'] = 'none'
[264] Fix | Delete
[265] Fix | Delete
def MkChoosers(nb, name):
[266] Fix | Delete
w = nb.page(name)
[267] Fix | Delete
options = "label.padX 4"
[268] Fix | Delete
[269] Fix | Delete
til = Tix.LabelFrame(w, label='Chooser Widgets', options=options)
[270] Fix | Delete
cbx = Tix.LabelFrame(w, label='tixComboBox', options=options)
[271] Fix | Delete
ctl = Tix.LabelFrame(w, label='tixControl', options=options)
[272] Fix | Delete
sel = Tix.LabelFrame(w, label='tixSelect', options=options)
[273] Fix | Delete
opt = Tix.LabelFrame(w, label='tixOptionMenu', options=options)
[274] Fix | Delete
fil = Tix.LabelFrame(w, label='tixFileEntry', options=options)
[275] Fix | Delete
fbx = Tix.LabelFrame(w, label='tixFileSelectBox', options=options)
[276] Fix | Delete
tbr = Tix.LabelFrame(w, label='Tool Bar', options=options)
[277] Fix | Delete
[278] Fix | Delete
MkTitle(til.frame)
[279] Fix | Delete
MkCombo(cbx.frame)
[280] Fix | Delete
MkControl(ctl.frame)
[281] Fix | Delete
MkSelect(sel.frame)
[282] Fix | Delete
MkOptMenu(opt.frame)
[283] Fix | Delete
MkFileEnt(fil.frame)
[284] Fix | Delete
MkFileBox(fbx.frame)
[285] Fix | Delete
MkToolBar(tbr.frame)
[286] Fix | Delete
[287] Fix | Delete
# First column: comBox and selector
[288] Fix | Delete
cbx.form(top=0, left=0, right='%33')
[289] Fix | Delete
sel.form(left=0, right='&'+str(cbx), top=cbx)
[290] Fix | Delete
opt.form(left=0, right='&'+str(cbx), top=sel, bottom=-1)
[291] Fix | Delete
[292] Fix | Delete
# Second column: title .. etc
[293] Fix | Delete
til.form(left=cbx, top=0,right='%66')
[294] Fix | Delete
ctl.form(left=cbx, right='&'+str(til), top=til)
[295] Fix | Delete
fil.form(left=cbx, right='&'+str(til), top=ctl)
[296] Fix | Delete
tbr.form(left=cbx, right='&'+str(til), top=fil, bottom=-1)
[297] Fix | Delete
[298] Fix | Delete
#
[299] Fix | Delete
# Third column: file selection
[300] Fix | Delete
fbx.form(right=-1, top=0, left='%66')
[301] Fix | Delete
[302] Fix | Delete
def MkCombo(w):
[303] Fix | Delete
options="label.width %d label.anchor %s entry.width %d" % (10, Tix.E, 14)
[304] Fix | Delete
[305] Fix | Delete
static = Tix.ComboBox(w, label='Static', editable=0, options=options)
[306] Fix | Delete
editable = Tix.ComboBox(w, label='Editable', editable=1, options=options)
[307] Fix | Delete
history = Tix.ComboBox(w, label='History', editable=1, history=1,
[308] Fix | Delete
anchor=Tix.E, options=options)
[309] Fix | Delete
static.insert(Tix.END, 'January')
[310] Fix | Delete
static.insert(Tix.END, 'February')
[311] Fix | Delete
static.insert(Tix.END, 'March')
[312] Fix | Delete
static.insert(Tix.END, 'April')
[313] Fix | Delete
static.insert(Tix.END, 'May')
[314] Fix | Delete
static.insert(Tix.END, 'June')
[315] Fix | Delete
static.insert(Tix.END, 'July')
[316] Fix | Delete
static.insert(Tix.END, 'August')
[317] Fix | Delete
static.insert(Tix.END, 'September')
[318] Fix | Delete
static.insert(Tix.END, 'October')
[319] Fix | Delete
static.insert(Tix.END, 'November')
[320] Fix | Delete
static.insert(Tix.END, 'December')
[321] Fix | Delete
[322] Fix | Delete
editable.insert(Tix.END, 'Angola')
[323] Fix | Delete
editable.insert(Tix.END, 'Bangladesh')
[324] Fix | Delete
editable.insert(Tix.END, 'China')
[325] Fix | Delete
editable.insert(Tix.END, 'Denmark')
[326] Fix | Delete
editable.insert(Tix.END, 'Ecuador')
[327] Fix | Delete
[328] Fix | Delete
history.insert(Tix.END, '/usr/bin/ksh')
[329] Fix | Delete
history.insert(Tix.END, '/usr/local/lib/python')
[330] Fix | Delete
history.insert(Tix.END, '/var/adm')
[331] Fix | Delete
[332] Fix | Delete
static.pack(side=Tix.TOP, padx=5, pady=3)
[333] Fix | Delete
editable.pack(side=Tix.TOP, padx=5, pady=3)
[334] Fix | Delete
history.pack(side=Tix.TOP, padx=5, pady=3)
[335] Fix | Delete
[336] Fix | Delete
states = ['Bengal', 'Delhi', 'Karnataka', 'Tamil Nadu']
[337] Fix | Delete
[338] Fix | Delete
def spin_cmd(w, inc):
[339] Fix | Delete
idx = states.index(demo_spintxt.get()) + inc
[340] Fix | Delete
if idx < 0:
[341] Fix | Delete
idx = len(states) - 1
[342] Fix | Delete
elif idx >= len(states):
[343] Fix | Delete
idx = 0
[344] Fix | Delete
# following doesn't work.
[345] Fix | Delete
# return states[idx]
[346] Fix | Delete
demo_spintxt.set(states[idx]) # this works
[347] Fix | Delete
[348] Fix | Delete
def spin_validate(w):
[349] Fix | Delete
global states, demo_spintxt
[350] Fix | Delete
[351] Fix | Delete
try:
[352] Fix | Delete
i = states.index(demo_spintxt.get())
[353] Fix | Delete
except ValueError:
[354] Fix | Delete
return states[0]
[355] Fix | Delete
return states[i]
[356] Fix | Delete
# why this procedure works as opposed to the previous one beats me.
[357] Fix | Delete
[358] Fix | Delete
def MkControl(w):
[359] Fix | Delete
global demo_spintxt
[360] Fix | Delete
[361] Fix | Delete
options="label.width %d label.anchor %s entry.width %d" % (10, Tix.E, 13)
[362] Fix | Delete
[363] Fix | Delete
demo_spintxt = Tix.StringVar()
[364] Fix | Delete
demo_spintxt.set(states[0])
[365] Fix | Delete
simple = Tix.Control(w, label='Numbers', options=options)
[366] Fix | Delete
spintxt = Tix.Control(w, label='States', variable=demo_spintxt,
[367] Fix | Delete
options=options)
[368] Fix | Delete
spintxt['incrcmd'] = lambda w=spintxt: spin_cmd(w, 1)
[369] Fix | Delete
spintxt['decrcmd'] = lambda w=spintxt: spin_cmd(w, -1)
[370] Fix | Delete
spintxt['validatecmd'] = lambda w=spintxt: spin_validate(w)
[371] Fix | Delete
[372] Fix | Delete
simple.pack(side=Tix.TOP, padx=5, pady=3)
[373] Fix | Delete
spintxt.pack(side=Tix.TOP, padx=5, pady=3)
[374] Fix | Delete
[375] Fix | Delete
def MkSelect(w):
[376] Fix | Delete
options = "label.anchor %s" % Tix.CENTER
[377] Fix | Delete
[378] Fix | Delete
sel1 = Tix.Select(w, label='Mere Mortals', allowzero=1, radio=1,
[379] Fix | Delete
orientation=Tix.VERTICAL,
[380] Fix | Delete
labelside=Tix.TOP,
[381] Fix | Delete
options=options)
[382] Fix | Delete
sel2 = Tix.Select(w, label='Geeks', allowzero=1, radio=0,
[383] Fix | Delete
orientation=Tix.VERTICAL,
[384] Fix | Delete
labelside= Tix.TOP,
[385] Fix | Delete
options=options)
[386] Fix | Delete
[387] Fix | Delete
sel1.add('eat', text='Eat')
[388] Fix | Delete
sel1.add('work', text='Work')
[389] Fix | Delete
sel1.add('play', text='Play')
[390] Fix | Delete
sel1.add('party', text='Party')
[391] Fix | Delete
sel1.add('sleep', text='Sleep')
[392] Fix | Delete
[393] Fix | Delete
sel2.add('eat', text='Eat')
[394] Fix | Delete
sel2.add('prog1', text='Program')
[395] Fix | Delete
sel2.add('prog2', text='Program')
[396] Fix | Delete
sel2.add('prog3', text='Program')
[397] Fix | Delete
sel2.add('sleep', text='Sleep')
[398] Fix | Delete
[399] Fix | Delete
sel1.pack(side=Tix.LEFT, padx=5, pady=3, fill=Tix.X)
[400] Fix | Delete
sel2.pack(side=Tix.LEFT, padx=5, pady=3, fill=Tix.X)
[401] Fix | Delete
[402] Fix | Delete
def MkOptMenu(w):
[403] Fix | Delete
options='menubutton.width 15 label.anchor %s' % Tix.E
[404] Fix | Delete
[405] Fix | Delete
m = Tix.OptionMenu(w, label='File Format : ', options=options)
[406] Fix | Delete
m.add_command('text', label='Plain Text')
[407] Fix | Delete
m.add_command('post', label='PostScript')
[408] Fix | Delete
m.add_command('format', label='Formatted Text')
[409] Fix | Delete
m.add_command('html', label='HTML')
[410] Fix | Delete
m.add_command('sep')
[411] Fix | Delete
m.add_command('tex', label='LaTeX')
[412] Fix | Delete
m.add_command('rtf', label='Rich Text Format')
[413] Fix | Delete
[414] Fix | Delete
m.pack(fill=Tix.X, padx=5, pady=3)
[415] Fix | Delete
[416] Fix | Delete
def MkFileEnt(w):
[417] Fix | Delete
msg = Tix.Message(w,
[418] Fix | Delete
relief=Tix.FLAT, width=240, anchor=Tix.N,
[419] Fix | Delete
text='Press the "open file" icon button and a TixFileSelectDialog will popup.')
[420] Fix | Delete
ent = Tix.FileEntry(w, label='Select a file : ')
[421] Fix | Delete
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
[422] Fix | Delete
ent.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
[423] Fix | Delete
[424] Fix | Delete
def MkFileBox(w):
[425] Fix | Delete
"""The FileSelectBox is a Motif-style box with various enhancements.
[426] Fix | Delete
For example, you can adjust the size of the two listboxes
[427] Fix | Delete
and your past selections are recorded.
[428] Fix | Delete
"""
[429] Fix | Delete
msg = Tix.Message(w,
[430] Fix | Delete
relief=Tix.FLAT, width=240, anchor=Tix.N,
[431] Fix | Delete
text='The Tix FileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.')
[432] Fix | Delete
box = Tix.FileSelectBox(w)
[433] Fix | Delete
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
[434] Fix | Delete
box.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
[435] Fix | Delete
[436] Fix | Delete
def MkToolBar(w):
[437] Fix | Delete
"""The Select widget is also good for arranging buttons in a tool bar.
[438] Fix | Delete
"""
[439] Fix | Delete
global demo
[440] Fix | Delete
[441] Fix | Delete
options='frame.borderWidth 1'
[442] Fix | Delete
[443] Fix | Delete
msg = Tix.Message(w,
[444] Fix | Delete
relief=Tix.FLAT, width=240, anchor=Tix.N,
[445] Fix | Delete
text='The Select widget is also good for arranging buttons in a tool bar.')
[446] Fix | Delete
bar = Tix.Frame(w, bd=2, relief=Tix.RAISED)
[447] Fix | Delete
font = Tix.Select(w, allowzero=1, radio=0, label='', options=options)
[448] Fix | Delete
para = Tix.Select(w, allowzero=0, radio=1, label='', options=options)
[449] Fix | Delete
[450] Fix | Delete
font.add('bold', bitmap='@' + demo.dir + '/bitmaps/bold.xbm')
[451] Fix | Delete
font.add('italic', bitmap='@' + demo.dir + '/bitmaps/italic.xbm')
[452] Fix | Delete
font.add('underline', bitmap='@' + demo.dir + '/bitmaps/underline.xbm')
[453] Fix | Delete
font.add('capital', bitmap='@' + demo.dir + '/bitmaps/capital.xbm')
[454] Fix | Delete
[455] Fix | Delete
para.add('left', bitmap='@' + demo.dir + '/bitmaps/leftj.xbm')
[456] Fix | Delete
para.add('right', bitmap='@' + demo.dir + '/bitmaps/rightj.xbm')
[457] Fix | Delete
para.add('center', bitmap='@' + demo.dir + '/bitmaps/centerj.xbm')
[458] Fix | Delete
para.add('justify', bitmap='@' + demo.dir + '/bitmaps/justify.xbm')
[459] Fix | Delete
[460] Fix | Delete
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
[461] Fix | Delete
bar.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
[462] Fix | Delete
font.pack({'in':bar}, side=Tix.LEFT, padx=3, pady=3)
[463] Fix | Delete
para.pack({'in':bar}, side=Tix.LEFT, padx=3, pady=3)
[464] Fix | Delete
[465] Fix | Delete
def MkTitle(w):
[466] Fix | Delete
msg = Tix.Message(w,
[467] Fix | Delete
relief=Tix.FLAT, width=240, anchor=Tix.N,
[468] Fix | Delete
text='There are many types of "chooser" widgets that allow the user to input different types of information')
[469] Fix | Delete
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
[470] Fix | Delete
[471] Fix | Delete
def MkScroll(nb, name):
[472] Fix | Delete
w = nb.page(name)
[473] Fix | Delete
options='label.padX 4'
[474] Fix | Delete
[475] Fix | Delete
sls = Tix.LabelFrame(w, label='Tix.ScrolledListBox', options=options)
[476] Fix | Delete
swn = Tix.LabelFrame(w, label='Tix.ScrolledWindow', options=options)
[477] Fix | Delete
stx = Tix.LabelFrame(w, label='Tix.ScrolledText', options=options)
[478] Fix | Delete
[479] Fix | Delete
MkSList(sls.frame)
[480] Fix | Delete
MkSWindow(swn.frame)
[481] Fix | Delete
MkSText(stx.frame)
[482] Fix | Delete
[483] Fix | Delete
sls.form(top=0, left=0, right='%33', bottom=-1)
[484] Fix | Delete
swn.form(top=0, left=sls, right='%66', bottom=-1)
[485] Fix | Delete
stx.form(top=0, left=swn, right=-1, bottom=-1)
[486] Fix | Delete
[487] Fix | Delete
[488] Fix | Delete
def MkSList(w):
[489] Fix | Delete
"""This TixScrolledListBox is configured so that it uses scrollbars
[490] Fix | Delete
only when it is necessary. Use the handles to resize the listbox and
[491] Fix | Delete
watch the scrollbars automatically appear and disappear. """
[492] Fix | Delete
top = Tix.Frame(w, width=300, height=330)
[493] Fix | Delete
bot = Tix.Frame(w)
[494] Fix | Delete
msg = Tix.Message(top,
[495] Fix | Delete
relief=Tix.FLAT, width=200, anchor=Tix.N,
[496] Fix | Delete
text='This TixScrolledListBox is configured so that it uses scrollbars only when it is necessary. Use the handles to resize the listbox and watch the scrollbars automatically appear and disappear.')
[497] Fix | Delete
[498] Fix | Delete
list = Tix.ScrolledListBox(top, scrollbar='auto')
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function