| 1 | import Tkinter |
| 2 | import Test |
| 3 | import Pmw |
| 4 | |
| 5 | Test.initialise() |
| 6 | |
| 7 | c = Pmw.CounterDialog |
| 8 | |
| 9 | kw_1 = { |
| 10 | 'counter_labelpos': 'n', |
| 11 | 'counter_buttonaspect': 2.0, |
| 12 | 'counter_autorepeat': 0, |
| 13 | 'counter_initwait': 1000, |
| 14 | 'counter_padx': 5, |
| 15 | 'counter_pady': 5, |
| 16 | 'counter_repeatrate': 20, |
| 17 | 'label_text' : 'Counter:', |
| 18 | 'buttons' : ('OK', 'Cancel', 'Help'), |
| 19 | } |
| 20 | tests_1 = ( |
| 21 | (Test.num_options, (), 11), |
| 22 | ('counter_Arrow_borderwidth', 10), |
| 23 | ('counter_hull_background', 'yellow'), |
| 24 | ('command', Test.callback1), |
| 25 | ('hull_cursor', 'gumby'), |
| 26 | ('counter_datatype', 'time'), |
| 27 | ('counter_datatype', 'numeric'), |
| 28 | ('entry_borderwidth', 6), |
| 29 | ('entry_relief', 'raised'), |
| 30 | ('entry_exportselection', 0), |
| 31 | ('entry_foreground', 'blue'), |
| 32 | ('hull_highlightcolor', 'Red'), |
| 33 | ('hull_highlightthickness', 2), |
| 34 | ('counter_increment', 1), |
| 35 | ('entry_insertbackground', 'Yellow'), |
| 36 | ('entry_insertbackground', 'Black'), |
| 37 | ('entry_insertborderwidth', 1), |
| 38 | ('entry_insertborderwidth', 0), |
| 39 | ('entry_insertofftime', 400), |
| 40 | ('entry_insertontime', 700), |
| 41 | ('entry_insertwidth', 3), |
| 42 | ('entryfield_invalidcommand', Test.callback), |
| 43 | ('entry_show', '*'), |
| 44 | ('entry_background', 'red'), |
| 45 | (c.setentry, '69', 1), |
| 46 | ('entry_justify', 'right'), |
| 47 | ('entry_justify', 'center'), |
| 48 | ('entry_justify', 'left'), |
| 49 | ('label_text', 'Label'), |
| 50 | ('entry_relief', 'raised'), |
| 51 | ('entry_relief', 'sunken'), |
| 52 | ('entry_state', 'disabled'), |
| 53 | ('entry_state', 'normal'), |
| 54 | ('entry_background', 'GhostWhite'), |
| 55 | ('entryfield_validate', 'numeric'), |
| 56 | ('entryfield_validate', 'alphabetic'), |
| 57 | ('entry_width', 30), |
| 58 | ('relief', 'bogus', 'KeyError: Unknown option "relief" for CounterDialog'), |
| 59 | (c.interior, (), Tkinter.Frame), |
| 60 | (c.insert, ('end', 69)), |
| 61 | (c.increment, ()), |
| 62 | (c.decrement, ()), |
| 63 | ('defaultbutton', 1), |
| 64 | (c.invoke, (), 'Cancel'), |
| 65 | (c.clear, ()), |
| 66 | (c.get, (), ''), |
| 67 | (c.insert, ('end', 'Test String')), |
| 68 | (c.get, (), 'Test String'), |
| 69 | (c.delete, (0, 'end')), |
| 70 | (c.insert, ('end', 'Another Test')), |
| 71 | (c.icursor, 'end'), |
| 72 | (c.index, 'end', 12), |
| 73 | (c.selection_from, 0), |
| 74 | (c.selection_to, 'end'), |
| 75 | (c.xview, '3'), |
| 76 | (c.clear, ()), |
| 77 | ) |
| 78 | |
| 79 | kw_2 = { |
| 80 | 'buttonboxpos': 'e', |
| 81 | 'counter_labelpos': 'w', |
| 82 | 'label_text' : 'Another counter', |
| 83 | 'buttonbox_pady': 25, |
| 84 | 'buttons' : ('OK', 'Cancel'), |
| 85 | } |
| 86 | tests_2 = ( |
| 87 | (c.title, 'CounterDialog 2', ''), |
| 88 | ) |
| 89 | |
| 90 | alltests = ( |
| 91 | (tests_1, kw_1), |
| 92 | (tests_2, kw_2), |
| 93 | ) |
| 94 | |
| 95 | testData = ((c, alltests),) |
| 96 | |
| 97 | if __name__ == '__main__': |
| 98 | Test.runTests(testData) |