desktop

tests/test_dialog.py

49:4d5b60c416ca
2007-12-13 paulb [project @ 2007-12-13 21:41:15 by paulb] Added command result conversions to Python types. Fixed some type errors.
     1 #!/usr/bin/env python     2      3 import desktop.dialog     4      5 def test_open(obj, desktop=None):     6     try:     7         return obj.open(desktop)     8     except OSError:     9         return None    10     11 """    12 obj = desktop.dialog.Question("Are you sure?", 40, 5)    13 print test_open(obj)    14 print test_open(obj, "KDE")    15 print test_open(obj, "GNOME")    16 print test_open(obj, "X11")    17     18 obj = desktop.dialog.Message("Hello world!", 40, 5)    19 print test_open(obj)    20 print test_open(obj, "KDE")    21 print test_open(obj, "GNOME")    22 print test_open(obj, "X11")    23     24 obj = desktop.dialog.Warning("Beware of the penguin!", 40, 5)    25 print test_open(obj)    26 print test_open(obj, "KDE")    27 print test_open(obj, "GNOME")    28 print test_open(obj, "X11")    29     30 obj = desktop.dialog.Error("Penguin invasion complete!", 40, 5)    31 print test_open(obj)    32 print test_open(obj, "KDE")    33 print test_open(obj, "GNOME")    34 print test_open(obj, "X11")    35 """    36     37 obj = desktop.dialog.Menu("Choose an animal", ["*", "Animal"], width=40, height=15, list_height=5)    38 obj.add("a", "Antelope")    39 obj.add("b", "Badger")    40 obj.add("c", "Cow")    41 obj.add("d", "Dog")    42 obj.add("e", "Elephant")    43 obj.add("f", "Fox")    44 obj.add("g", "Giraffe")    45 obj.add("h", "Horse")    46 obj.add("i", "Iguana")    47 print test_open(obj)    48 print test_open(obj, "KDE")    49 print test_open(obj, "GNOME")    50 print test_open(obj, "X11")    51     52 obj = desktop.dialog.CheckList("Choose some animals", ["S", "*", "Animal"], width=40, height=15, list_height=5)    53 obj.add("a", "Antelope")    54 obj.add("b", "Badger", 1)    55 obj.add("c", "Cow", 0)    56 obj.add("d", "Dog")    57 obj.add("e", "Elephant")    58 obj.add("f", "Fox", 1)    59 obj.add("g", "Giraffe")    60 obj.add("h", "Horse")    61 obj.add("i", "Iguana")    62 print test_open(obj)    63 print test_open(obj, "KDE")    64 print test_open(obj, "GNOME")    65 print test_open(obj, "X11")    66     67 # vim: tabstop=4 expandtab shiftwidth=4