from GUI import Window, View, CheckBox, Button, Label, \
         RadioButton, RadioGroup, TextField, ScrollFrame, application
from TestViews import TestView, BigTestView

def pushed_it():
    print "Button pushed."

def checked_it():
    print "Check boxes changed to:", cb1.on, cb2.on

def option_chosen():
    print "Hoopy option %d chosen" % rg.value

def main():
    global cb1, cb2, rg

    win = Window(title = "Place Me By Your Side", width = 700, height = 500)

    view1 = TestView(width = 300, height = 200)

    cb1 = CheckBox(title = "Check Me!", action = checked_it)

    cb2 = CheckBox(title = "Check Me Too!", action = checked_it)

    rbs = []
    for i in xrange(1, 4):	
        rb = RadioButton(title = "Hoopy Option %d" % i, value = i)
        rbs.append(rb)

    rg = RadioGroup(rbs, action = option_chosen)

    pb = Button(title = "Push Me!", action = pushed_it)

    view2 = BigTestView(width = 300, height = 300)

    label = Label(text = "Flavour:")

    entry = TextField(width = 200, height = 28)

    win.place(view1, left = 10, top = 10, border = 1)

    win.place_row([cb1, cb2], left = 10, top = (view1, 20), spacing = 20)

    win.place_column(rbs, left = view1 + 20, top = 10)

    win.place(pb, right = -20, bottom = -10, sticky = 'se')

    view2_sf = ScrollFrame(view2)
    #view2_sf.width = 500 ###
    #win.add(view2_sf) ###
    win.place(view2_sf, 
        left = rbs[0] + 20, top = 10, 
        #left = 20, top = 20, ###
        right = -20,
        #bottom = -20, ###
        bottom = pb - 10,
        sticky = 'nsew', border = 1)
    
    win.place(label, left = 10, top = (cb1, 20))

    win.place(entry, left = 10, top = (label, 10), border = 1)

    win.show()

    application().run()

main()
