# The salutations app will take in a name and randomly generate a greeting
import tkinter as tk 
import random
# Window
window = tk.Tk()
window.title('Salutations')
window.geometry('400x400')
window.configure(background = 'dim gray')

# Functions
def phrase_generator():
    # Create a list of phrases
    phrase = ['Hello', 'Whats up', 'Howdy', 'Aloha']
    # get name from the entry1 field
    name = str(entry1.get())

    return random.choice(phrase) + " " + name

def phrase_display():
    # Get greetins from a phrase_generator
    greeting = phrase_generator()

    # This creates the text field with our greeting
    greeting_display = tk.Text(master=window, height=10, width=30)
    greeting_display.grid(column = 0, row = 3)
    # need tk.END to actually place the line IDK why
    greeting_display.insert(tk.END, greeting)
    greeting_display.configure(state='disabled')

# label
label1 = tk.Label(text="How you doin")
label1.grid(column=0, row=0)

label2 = tk.Label(text = 'What is your name?')
label2.grid(column=0, row=1)

# Entry
entry1 = tk.Entry()
entry1.grid(column=1, row=1)

# Button
button1 = tk.Button(text='Click Me!', command=phrase_display)
button1.grid(column=0, row=2)


window.mainloop()