File: Colors_test.py

package info (click to toggle)
python-pmw 1.2-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,024 kB
  • ctags: 3,802
  • sloc: python: 17,143; makefile: 41
file content (46 lines) | stat: -rw-r--r-- 1,045 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Tests for Pmw color handling.

import Tkinter
import Test
import Pmw

Test.initialise()
testData = ()

defaultPalette = Pmw.Color.getdefaultpalette(Test.root)

c = Tkinter.Button

colors = ('red', 'orange', 'yellow', 'green', 'blue', 'purple', 'white')
normalcolors = map(Pmw.Color.changebrightness,
	(Test.root,) * len(colors), colors, (0.85,) * len(colors))

kw = {}
tests = (
  (Pmw.Color.setscheme, (Test.root, normalcolors[0]), {'foreground' : 'white'}),
)
testData = testData + ((c, ((tests, kw),)),)

for color in normalcolors[1:]:
    kw = {'text' : color}
    tests = (
      (c.pack, ()),
      ('state', 'active'),
    )
    testData = testData + ((c, ((tests, kw),)),)

    kw = {}
    tests = (
      (Pmw.Color.setscheme, (Test.root, color), {'foreground' : 'red'}),
    )
    testData = testData + ((c, ((tests, kw),)),)

# Restore the default colors.
kw = {}
tests = (
  (Pmw.Color.setscheme, (Test.root,), defaultPalette),
)
testData = testData + ((c, ((tests, kw),)),)

if __name__ == '__main__':
    Test.runTests(testData)