1 title = 'Pmw.ScrolledText demonstration'
3 # Import Pmw from this directory tree.
5 sys.path[:0] = ['../../..']
14 def __init__(self, parent):
16 # Create the ScrolledText with headers.
17 fixedFont = Pmw.logicalfont('Fixed')
18 self.st = Pmw.ScrolledText(parent,
21 label_text='ScrolledText with headers',
29 text_font = fixedFont,
30 Header_font = fixedFont,
31 Header_foreground = 'blue',
33 rowcolumnheader_width = 3,
40 self.st.pack(padx = 5, pady = 5, fill = 'both', expand = 1)
42 funcs = 'atan cos cosh exp log log10 sin sinh sqrt tan tanh'
43 funcs = string.split(funcs)
45 # Create the header for the row headers
46 self.st.component('rowcolumnheader').insert('end', 'x')
48 # Create the column headers
50 for column in range(len(funcs)):
51 headerLine = headerLine + ('%-7s ' % (funcs[column],))
52 headerLine = headerLine[:-3]
53 self.st.component('columnheader').insert('0.0', headerLine)
55 self.st.tag_configure('yellow', background = 'yellow')
57 # Create the data rows and the row headers
60 for row in range(1, numRows):
63 for column in range(len(funcs)):
64 value = eval('math.' + funcs[column] + '(' + str(x) + ')')
67 tag1 = '%d.%d' % (row, len(dataLine))
68 tag2 = '%d.%d' % (row, len(dataLine) + len(data))
71 data = '%-7s' % (data,)
72 dataLine = dataLine + data + ' '
73 dataLine = dataLine[:-3]
74 header = '%.1f' % (x,)
76 dataLine = dataLine + '\n'
77 header = header + '\n'
78 self.st.insert('end', dataLine)
79 self.st.component('rowheader').insert('end', header)
80 apply(self.st.tag_add, ('yellow',) + tuple(tagList))
82 # Prevent users' modifying text and headers
84 text_state = 'disabled',
85 Header_state = 'disabled',
88 ######################################################################
90 # Create demo in root window for testing.
91 if __name__ == '__main__':
96 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
97 exitButton.pack(side = 'bottom')