paulb@48 | 1 | #!/usr/bin/env python |
paulb@48 | 2 | |
paulb@48 | 3 | import desktop.dialog |
paulb@48 | 4 | |
paulb@48 | 5 | def test_open(obj, desktop=None): |
paulb@48 | 6 | try: |
paulb@48 | 7 | return obj.open(desktop) |
paulb@48 | 8 | except OSError: |
paulb@48 | 9 | return None |
paulb@48 | 10 | |
paulb@50 | 11 | def test_question(): |
paulb@50 | 12 | obj = desktop.dialog.Question("Are you sure?", 40, 5) |
paulb@50 | 13 | print test_open(obj) |
paulb@50 | 14 | print test_open(obj, "KDE") |
paulb@50 | 15 | print test_open(obj, "GNOME") |
paulb@50 | 16 | print test_open(obj, "X11") |
paulb@50 | 17 | |
paulb@50 | 18 | def test_message(): |
paulb@50 | 19 | obj = desktop.dialog.Message("Hello world!", 40, 5) |
paulb@50 | 20 | print test_open(obj) |
paulb@50 | 21 | print test_open(obj, "KDE") |
paulb@50 | 22 | print test_open(obj, "GNOME") |
paulb@50 | 23 | print test_open(obj, "X11") |
paulb@48 | 24 | |
paulb@50 | 25 | def test_warning(): |
paulb@50 | 26 | obj = desktop.dialog.Warning("Beware of the penguin!", 40, 5) |
paulb@50 | 27 | print test_open(obj) |
paulb@50 | 28 | print test_open(obj, "KDE") |
paulb@50 | 29 | print test_open(obj, "GNOME") |
paulb@50 | 30 | print test_open(obj, "X11") |
paulb@50 | 31 | |
paulb@50 | 32 | def test_error(): |
paulb@50 | 33 | obj = desktop.dialog.Error("Penguin invasion complete!", 40, 5) |
paulb@50 | 34 | print test_open(obj) |
paulb@50 | 35 | print test_open(obj, "KDE") |
paulb@50 | 36 | print test_open(obj, "GNOME") |
paulb@50 | 37 | print test_open(obj, "X11") |
paulb@48 | 38 | |
paulb@50 | 39 | def test_menu(): |
paulb@50 | 40 | obj = desktop.dialog.Menu("Choose an animal", ["Animal"], width=40, height=15, list_height=5) |
paulb@50 | 41 | obj.add("a", "Antelope") |
paulb@50 | 42 | obj.add("b", "Badger") |
paulb@50 | 43 | obj.add("c", "Cow") |
paulb@50 | 44 | obj.add("d", "Dog") |
paulb@50 | 45 | obj.add("e", "Elephant") |
paulb@50 | 46 | obj.add("f", "Fox") |
paulb@50 | 47 | obj.add("g", "Giraffe") |
paulb@50 | 48 | obj.add("h", "Horse") |
paulb@50 | 49 | obj.add("i", "Iguana") |
paulb@50 | 50 | print repr(test_open(obj)) |
paulb@50 | 51 | print repr(test_open(obj, "KDE")) |
paulb@50 | 52 | print repr(test_open(obj, "GNOME")) |
paulb@50 | 53 | print repr(test_open(obj, "X11")) |
paulb@48 | 54 | |
paulb@50 | 55 | def test_checklist(): |
paulb@50 | 56 | obj = desktop.dialog.CheckList("Choose some animals", ["Animal"], width=40, height=15, list_height=5) |
paulb@50 | 57 | obj.add("a", "Antelope") |
paulb@50 | 58 | obj.add("b", "Badger", 1) |
paulb@50 | 59 | obj.add("c", "Cow", 0) |
paulb@50 | 60 | obj.add("d", "Dog") |
paulb@50 | 61 | obj.add("e", "Elephant") |
paulb@50 | 62 | obj.add("f", "Fox", 1) |
paulb@50 | 63 | obj.add("g", "Giraffe") |
paulb@50 | 64 | obj.add("h", "Horse") |
paulb@50 | 65 | obj.add("i", "Iguana") |
paulb@50 | 66 | print repr(test_open(obj)) |
paulb@50 | 67 | print repr(test_open(obj, "KDE")) |
paulb@50 | 68 | print repr(test_open(obj, "GNOME")) |
paulb@50 | 69 | print repr(test_open(obj, "X11")) |
paulb@48 | 70 | |
paulb@50 | 71 | def test_radiolist(): |
paulb@50 | 72 | obj = desktop.dialog.RadioList("Choose one animal", ["Animal"], width=40, height=15, list_height=5) |
paulb@50 | 73 | obj.add("a", "Antelope") |
paulb@50 | 74 | obj.add("b", "Badger", 1) |
paulb@50 | 75 | obj.add("c", "Cow", 0) |
paulb@50 | 76 | obj.add("d", "Dog") |
paulb@50 | 77 | obj.add("e", "Elephant") |
paulb@50 | 78 | obj.add("f", "Fox", 1) |
paulb@50 | 79 | obj.add("g", "Giraffe") |
paulb@50 | 80 | obj.add("h", "Horse") |
paulb@50 | 81 | obj.add("i", "Iguana") |
paulb@50 | 82 | print repr(test_open(obj)) |
paulb@50 | 83 | print repr(test_open(obj, "KDE")) |
paulb@50 | 84 | print repr(test_open(obj, "GNOME")) |
paulb@50 | 85 | print repr(test_open(obj, "X11")) |
paulb@50 | 86 | |
paulb@50 | 87 | def test_pulldown(): |
paulb@50 | 88 | obj = desktop.dialog.Pulldown("Choose an animal", ["Animal"], width=40, height=15, list_height=5) |
paulb@50 | 89 | obj.add("Antelope") |
paulb@50 | 90 | obj.add("Badger") |
paulb@50 | 91 | obj.add("Cow") |
paulb@50 | 92 | obj.add("Dog") |
paulb@50 | 93 | obj.add("Elephant") |
paulb@50 | 94 | obj.add("Fox") |
paulb@50 | 95 | obj.add("Giraffe") |
paulb@50 | 96 | obj.add("Horse") |
paulb@50 | 97 | obj.add("Iguana") |
paulb@50 | 98 | print repr(test_open(obj)) |
paulb@50 | 99 | print repr(test_open(obj, "KDE")) |
paulb@50 | 100 | print repr(test_open(obj, "GNOME")) |
paulb@50 | 101 | print repr(test_open(obj, "X11")) |
paulb@48 | 102 | |
paulb@50 | 103 | def test_input(): |
paulb@50 | 104 | obj = desktop.dialog.Input("Enter your name!", "Monty", 40, 5) |
paulb@50 | 105 | print repr(test_open(obj)) |
paulb@50 | 106 | print repr(test_open(obj, "KDE")) |
paulb@50 | 107 | print repr(test_open(obj, "GNOME")) |
paulb@50 | 108 | print repr(test_open(obj, "X11")) |
paulb@50 | 109 | |
paulb@50 | 110 | def test_password(): |
paulb@50 | 111 | obj = desktop.dialog.Password("Enter your password!", "Python", 40, 5) |
paulb@50 | 112 | print repr(test_open(obj)) |
paulb@50 | 113 | print repr(test_open(obj, "KDE")) |
paulb@50 | 114 | print repr(test_open(obj, "GNOME")) |
paulb@50 | 115 | print repr(test_open(obj, "X11")) |
paulb@50 | 116 | |
paulb@50 | 117 | def test_textfile(): |
paulb@50 | 118 | obj = desktop.dialog.TextFile("README.txt", "Showing file...", 80, 25) |
paulb@50 | 119 | print repr(test_open(obj)) |
paulb@50 | 120 | print repr(test_open(obj, "KDE")) |
paulb@50 | 121 | print repr(test_open(obj, "GNOME")) |
paulb@50 | 122 | print repr(test_open(obj, "X11")) |
paulb@50 | 123 | |
paulb@50 | 124 | test_question() |
paulb@50 | 125 | test_message() |
paulb@50 | 126 | test_warning() |
paulb@50 | 127 | test_error() |
paulb@50 | 128 | test_menu() |
paulb@50 | 129 | test_checklist() |
paulb@50 | 130 | test_radiolist() |
paulb@50 | 131 | test_pulldown() |
paulb@50 | 132 | test_input() |
paulb@50 | 133 | test_password() |
paulb@50 | 134 | test_textfile() |
paulb@48 | 135 | |
paulb@48 | 136 | # vim: tabstop=4 expandtab shiftwidth=4 |