Tkinter Tutorial 8

For the purpose of clarity, here is the full magic 8 gui program,

#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#!/usr/bin/env python
 
import random
import Tkinter # note use of caps
from Tkinter import *
 
#set up
window = Tk()
window.title('Magic 8')
window.geometry("310x100") #wxh
window.resizable(0,0)
 
RESPONSES = ["It is certain",
             "It is decidedly so",
             "Without a doubt",
             "Yes definitely",
             "You may rely on it",
             "As I see it yes",
             "Most likely",
             "Outlook good",
             "Yes",
             "Signs point to yes",
             "Reply hazy try again",
             "Ask again later",
             "Better not tell you now",
             "Cannot predict now",
             "Concentrate and ask again",
             "Don't count on it",
             "My reply is no",
             "My sources say no",
             "Outlook not so good",
             "Very doubtful"] 
 
def response():
 
	msg = "error : must be a text value"
 
	i = circletext.get()
	y = i.isdigit()
	l = len(circletext.get())
	#print l
	if y == True or l == 0:
		circletext.insert(0,(msg))
 
	else:	
		x = random.choice(RESPONSES)
		circletext2.delete(0, END) # clear prev output
		circletext2.insert(0,str(x)) # insert response
 
def clear():
	circletext.delete(0, END) # clear input box
	circletext2.delete(0, END) # clear output box
 
#define labels - cannot share same name as function
box1 = Label(window, text="Question: ")
box2 = Label(window, text="Answer: ")       
 
#place labels
box1.grid(row = 1, column = 1, padx = 5, pady = 5)
box2.grid(row = 2, column = 1, padx = 5, pady = 5)
 
#define entry box 
 
circleVar = StringVar()
circletext = Entry(window, textvariable=circleVar)
 
#define out box 
 
circleVar2 = StringVar()
circletext2 = Entry(window, textvariable=circleVar2)
 
#display boxes
circletext.grid(row = 1, column = 2,) #question box
circletext2.grid(row = 2, column = 2,) #response box
 
#define buttons
 
response = Button( window, text ='response', command=response)
clear = Button( window, text ='Clear', command=clear)
exitbtn = Button( window, text ='Exit', command=exit)
 
#place buttons
 
response.grid(row = 4, column = 1, padx = 1, pady = 1)
clear.grid(row = 4, column = 2, padx = 1, pady = 1)
exitbtn.grid(row = 4, column = 3, padx = 1, pady = 1)
 
#display window
 
window.mainloop()
 
#while(True):
#raw_input("Enter your question: ")

Feel free to copy / paste and run.