Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | # Tests for Pmw color handling. |
2 | ||
3 | import Tkinter | |
4 | import Test | |
5 | import Pmw | |
6 | ||
7 | Test.initialise() | |
8 | testData = () | |
9 | ||
10 | defaultPalette = Pmw.Color.getdefaultpalette(Test.root) | |
11 | ||
12 | c = Tkinter.Button | |
13 | ||
14 | colors = ('red', 'orange', 'yellow', 'green', 'blue', 'purple', 'white') | |
15 | normalcolors = map(Pmw.Color.changebrightness, | |
16 | (Test.root,) * len(colors), colors, (0.85,) * len(colors)) | |
17 | ||
18 | kw = {} | |
19 | tests = ( | |
20 | (Pmw.Color.setscheme, (Test.root, normalcolors[0]), {'foreground' : 'white'}), | |
21 | ) | |
22 | testData = testData + ((c, ((tests, kw),)),) | |
23 | ||
24 | for color in normalcolors[1:]: | |
25 | kw = {'text' : color} | |
26 | tests = ( | |
27 | (c.pack, ()), | |
28 | ('state', 'active'), | |
29 | ) | |
30 | testData = testData + ((c, ((tests, kw),)),) | |
31 | ||
32 | kw = {} | |
33 | tests = ( | |
34 | (Pmw.Color.setscheme, (Test.root, color), {'foreground' : 'red'}), | |
35 | ) | |
36 | testData = testData + ((c, ((tests, kw),)),) | |
37 | ||
38 | # Restore the default colors. | |
39 | kw = {} | |
40 | tests = ( | |
41 | (Pmw.Color.setscheme, (Test.root,), defaultPalette), | |
42 | ) | |
43 | testData = testData + ((c, ((tests, kw),)),) | |
44 | ||
45 | if __name__ == '__main__': | |
46 | Test.runTests(testData) |