Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / demos / SpeedTest.py
CommitLineData
86530b38
AT
1title = 'Test of the speed of creating Pmw megawidgets'
2
3# Import Pmw from this directory tree.
4import sys
5sys.path[:0] = ['../../..']
6
7import time
8import Tkinter
9import Pmw
10
11class Demo:
12 def __init__(self, parent):
13 self.parent = parent
14
15 message = 'This is a test of the time\n' + \
16 'it takes to create 20 Pmw\nEntryField megawidgets.\n' + \
17 'Click on the button to create them.'
18 w = Tkinter.Label(parent, text = message)
19 w.pack(padx = 8, pady = 8)
20
21 # Create button to run speed test.
22 w = Tkinter.Button(parent,
23 text = 'Create 20 EntryFields',
24 command = self.createEntries)
25 w.pack(padx = 8, pady = 8)
26
27 def createEntries(self):
28 entryTop = Tkinter.Toplevel(self.parent)
29
30 startClock = time.clock()
31 fields = []
32 for num in range(20):
33 field = Pmw.EntryField(entryTop,
34 labelpos = 'w',
35 label_text='*' + ('*' * num),
36 hull_background = 'lightsteelblue',
37 label_background = 'lightsteelblue',
38 hull_highlightbackground = 'lightsteelblue',
39 label_highlightbackground = 'lightsteelblue',
40 entry_highlightbackground = 'lightsteelblue',
41 entry_background = 'aliceblue')
42 field.pack()
43 fields.append(field)
44
45 Pmw.alignlabels(fields)
46 print 'Time to create 20 EntryFields:', \
47 time.clock() - startClock, 'seconds'
48
49######################################################################
50
51# Create demo in root window for testing.
52if __name__ == '__main__':
53 root = Tkinter.Tk()
54 Pmw.initialise(root)
55 root.title(title)
56
57 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
58 exitButton.pack(side = 'bottom')
59 widget = Demo(root)
60 root.mainloop()