# Mastery test 2 - part 4


#   Create a program like the one in section 4 of lecture 13.


# NOTE:  When you want to run this program follow these three steps
# 1. Save the program from within IDLE
# 2. Double click on the source file (test_2_4.py) in a finder window
# 3. Double click on the application file (test_2_4) that is created
#
#
# The finished program should look like this:
# 
#  ---------------------------------------------------------------
# |                   ---------------------    -------   ------   |
# | Enter your name: |                     |  | Hello | | QUIT |  |
# |                   ---------------------    -------   ------   |
#  ---------------------------------------------------------------
# 
# When someone types their name (e.g. Brendan) into the text field and
# presses the Hello button then another window should pop up saying
# 'Hi there Brendan' like this:
#
#  ---------------------------------------
# |                              ------   |
# |   Hi there Brendan          |  OK  |  |
# |                              ------   |
#  ---------------------------------------
#
# The program should exit if the QUIT button is pressed.
#

from Tkinter import *
from tkMessageBox import *

def say_hi():
    showinfo(message="Hi there "+inVal.get())

root = Tk()
inVal = StringVar()

prompt_label = Label(root, text="Enter your name: ")
input_entry = Entry(root, textvar=inVal)
hi_button = Button(root, text="Hello", command=say_hi)
quit_button = Button(root, text="QUIT", command=root.quit)

prompt_label.grid(column=0,row=0)
input_entry.grid(column=1,row=0)
hi_button.grid(column=2,row=0)
quit_button.grid(column=3,row=0)

root.mainloop()
