# GUI1.py
# Written by Todd Wareham for CS 2500
"""
Executes basic Python GUI with examples of various widgets.

This version does not implement widget resizing under window size change.
"""

import sys
from Tkinter import *

## Root window setup

root = Tk()
root.title(sys.argv[0])

## Global GUI data-variables

iv1 = IntVar()
iv2 = IntVar()
dv  = DoubleVar()
sv1 = StringVar()
sv1.set("Left!")
sv2 = StringVar()

## Callback functions

def reset():
    sv2.set("Top2! : " + sv1.get())
    return

## GUI widgets

Label(root, text="Top1!").pack(side=TOP)
reset()
Label(root, textvariable=sv2).pack(side=TOP)
Scale(root, label="Top3!", variable=dv, from_=0.0, to=4.0, 
      tickinterval=1.0, resolution=0.5, showvalue=YES, 
      orient='horizontal').pack(side=TOP)

iv1.set(1)
Checkbutton(root, variable=iv1, text="Bottom!").pack(side=BOTTOM)
Button(root, text="Reset Top2", command=reset).pack(side=BOTTOM)

Entry(root, textvariable=sv1).pack(side=LEFT)

iv2.set(2)
Radiobutton(root, variable=iv2,  value=1, text="Right1").pack(side=RIGHT)
Radiobutton(root, variable=iv2,  value=2, text="Right2").pack(side=RIGHT)
Radiobutton(root, variable=iv2,  value=3, text="Right3").pack(side=RIGHT)

Button(root, text="Exit", command=sys.exit).pack()

## GUI execution

root.mainloop()
