]> SALOME platform Git repositories - tools/eficas.git/blob - Pmw/Pmw_1_2/demos/SpeedTest.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Pmw / Pmw_1_2 / demos / SpeedTest.py
1 title = 'Test of the speed of creating Pmw megawidgets'
2
3 # Import Pmw from this directory tree.
4 import sys
5 sys.path[:0] = ['../../..']
6
7 import time
8 import Tkinter
9 import Pmw
10
11 class 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.
52 if __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()