from GUI import Window, Button, RadioButton, RadioGroup, application

labels = ["Banana", "Chocolate", "Strawberry"]

def report():
    value = grp.value
    try:
        print labels[value], "selected"
    except (TypeError, IndexError):
        print "Value =", value

def set_to_chocolate():
    grp.value = 1

win = Window(width = 250, title = "Radio Groups")

grp = RadioGroup(action = report)

for i in xrange(0, 3):
    rbtn = RadioButton(
        position = (30, (i+1) * 30), 
        size = (200, 30),
        title = labels[i],
        group = grp, 
        value = i)
    win.add(rbtn)

pbtn = Button(title = "Set to Chocolate",
    position = (30, rbtn.bottom + 30),
    action = set_to_chocolate)
win.add(pbtn)

win.height = pbtn.bottom + 30
win.show()

application().run()
