File: OptionMenu_test.py

package info (click to toggle)
python-pmw 0.8.5-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,820 kB
  • ctags: 3,468
  • sloc: python: 14,898; makefile: 37; sh: 17
file content (52 lines) | stat: -rw-r--r-- 1,517 bytes parent folder | download
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
47
48
49
50
51
52
import Tkinter
import Test
import Pmw

Test.initialise()

c = Pmw.OptionMenu

kw_1 = {
    'labelpos' : 'nw',
    'label_text' : 'Option Menu:',
    'items' : ('Chips', 'Lollies', 'Junk', 'More junk'),
    'initialitem' : 1,
}
tests_1 = (
  (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
  (c.getcurselection, (), 'Lollies'),
  (c.index, 'Junk', 2),
  (c.index, 'Nowhere', 'ValueError: bad index "Nowhere": must be ' +
    'a name, a number, Pmw.END or Pmw.SELECT'),
  (c.index, Pmw.END, 3),
  (c.index, Pmw.SELECT, 1),
  (c.index, 1, 1),
  (c.invoke, 'Chips'),
  (c.getcurselection, (), 'Chips'),
  ('command', Test.callback1),
  (c.invoke, (), 'Chips'),
  (c.invoke, 'Lollies', 'Lollies'),
  (c.getcurselection, (), 'Lollies'),
  ('hull_background', 'yellow'),
  ('hull_show', 'X', 'TclError: unknown option "-show"'),
  (c.index, Pmw.SELECT, 1),
  (c.setitems, (('Chips', 'Junk', 'Lollies', 'More junk'),)),
  (c.index, Pmw.SELECT, 2),
  (c.setitems, (('Fruit', 'Vegetables', 'Cereals', 'Legumes'),)),
  (c.index, Pmw.SELECT, 0),
  (c.getcurselection, (), 'Fruit'),
  (c.setitems, (('Vegetables', 'Cereals', 'Legumes'), Pmw.END)),
  (c.getcurselection, (), 'Legumes'),
  (c.index, 'Vegetables', 0),
  (c.invoke, 'Legumes', 'Legumes'),
  ('hull_cursor', 'gumby'),
  ('label_foreground', 'Green'),
  ('label_foreground', 'Black'),
  ('label_highlightcolor', 'Red'),
  ('label_text', 'Label'),
)

testData = ((c, ((tests_1, kw_1),)),)

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