1 # Based on iwidgets2.2.0/tests/entryfield.test code.
10 'hello' : (lambda s: s == 'hello', len),
15 kw_1 = {'entry_width' : 12, 'labelpos' : 'n', 'label_text' : 'Entry Field:'}
17 (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
18 (Test.num_options, (), 10),
19 ('errorbackground', 'red'),
20 ('hull_background', 'yellow'),
21 ('label_background', 'yellow'),
22 ('entry_background', 'yellow'),
23 ('hull_show', 'X', 'TclError: unknown option "-show"'),
25 ('entry_borderwidth', 4),
26 ('entry_borderwidth', 2),
27 ('command', Test.callback),
28 ('hull_cursor', 'gumby'),
29 ('entry_exportselection', 0),
30 ('label_foreground', 'Green'),
31 ('entry_foreground', 'Green'),
32 ('label_foreground', 'Black'),
33 ('entry_foreground', 'Black'),
34 ('label_highlightcolor', 'Red'),
35 ('entry_highlightcolor', 'Red'),
36 ('entry_highlightthickness', 2),
37 ('entry_insertbackground', 'Yellow'),
38 ('entry_insertbackground', 'Black'),
39 ('entry_insertborderwidth', 1),
40 ('entry_insertborderwidth', 0),
41 ('entry_insertofftime', 400),
42 ('entry_insertontime', 700),
43 ('entry_insertwidth', 3),
44 ('invalidcommand', Test.callback),
45 ('entry_justify', 'right'),
46 ('entry_justify', 'center'),
47 ('entry_justify', 'left'),
48 ('label_text', 'Label'),
49 ('entry_relief', 'raised'),
50 ('entry_relief', 'sunken'),
51 ('entry_state', 'disabled'),
52 ('entry_state', 'normal'),
53 ('entry_background', 'GhostWhite'),
54 ('validate', 'numeric'),
55 ('validate', 'alphabetic'),
58 "ValueError: bad validate value \"bogus\": must be a function or one " +
59 "of the standard validators ('alphabetic', 'alphanumeric', 'date', " +
60 "'hexadecimal', 'integer', 'numeric', 'real', 'time') or extra " +
62 ('relief', 'bogus', 'KeyError: Unknown option "relief" for EntryField'),
64 (c.interior, (), Tkinter.Frame),
67 (c.insert, ('end', 'Test String')),
68 (c.get, (), 'Test String'),
69 (c.delete, (0, 'end')),
70 (c.insert, ('end', 'Another Test')),
73 (c.selection_from, 0),
74 (c.selection_to, 'end'),
77 (c.insert, ('end', '100')),
78 ('validate', {'validator' : 'real', 'min' : 10}),
79 (c.setentry, '50', 1),
80 (c.setentry, 'hello', 0),
81 ('extravalidators', _myValidators),
82 ('validate', 'hello'),
83 (c.setentry, 'hello', 1),
84 (c.setentry, 'foo', 0),
86 (c.cget, 'entry_background', 'GhostWhite'),
87 ('entry_textvariable', Test.stringvar),
88 (c.checkentry, (), 0),
89 (c.cget, 'entry_background', 'red'),
93 (c.pack, (), {'padx' : 10, 'pady' : 10}),
96 alltests = [(tests_1, kw_1)]
98 poslist = ('nw', 'n', 'ne', 'en', 'e', 'es', 'se', 's', 'sw', 'ws', 'w', 'wn',)
102 'label_text' : 'Entry Field',
104 alltests.append((tests_2, kw_2))
106 testData = ((c, alltests),)
108 if __name__ == '__main__':
109 Test.runTests(testData)