title
= 'Pmw.ScrolledText demonstration'
# Import Pmw from this directory tree.
sys
.path
[:0] = ['../../..']
def __init__(self
, parent
):
# Create the ScrolledText with headers.
fixedFont
= Pmw
.logicalfont('Fixed')
self
.st
= Pmw
.ScrolledText(parent
,
label_text
='ScrolledText with headers',
Header_foreground
= 'blue',
rowcolumnheader_width
= 3,
self
.st
.pack(padx
= 5, pady
= 5, fill
= 'both', expand
= 1)
funcs
= 'atan cos cosh exp log log10 sin sinh sqrt tan tanh'
funcs
= string
.split(funcs
)
# Create the header for the row headers
self
.st
.component('rowcolumnheader').insert('end', 'x')
# Create the column headers
for column
in range(len(funcs
)):
headerLine
= headerLine
+ ('%-7s ' % (funcs
[column
],))
headerLine
= headerLine
[:-3]
self
.st
.component('columnheader').insert('0.0', headerLine
)
self
.st
.tag_configure('yellow', background
= 'yellow')
# Create the data rows and the row headers
for row
in range(1, numRows
):
for column
in range(len(funcs
)):
value
= eval('math.' + funcs
[column
] + '(' + str(x
) + ')')
tag1
= '%d.%d' % (row
, len(dataLine
))
tag2
= '%d.%d' % (row
, len(dataLine
) + len(data
))
dataLine
= dataLine
+ data
+ ' '
dataLine
= dataLine
+ '\n'
self
.st
.insert('end', dataLine
)
self
.st
.component('rowheader').insert('end', header
)
apply(self
.st
.tag_add
, ('yellow',) + tuple(tagList
))
# Prevent users' modifying text and headers
Header_state
= 'disabled',
######################################################################
# Create demo in root window for testing.
if __name__
== '__main__':
exitButton
= Tkinter
.Button(root
, text
= 'Exit', command
= root
.destroy
)
exitButton
.pack(side
= 'bottom')