# Allison Obourn
# CS 115, Autumn 2021
# Lecture 33

# This program creates a GUI with two buttons and a label on a green
# background. They are centered horizontally and in one vertical column.
# The first says hello, the second world and the label starts with the text
# hello world. When the buttons are pressed a message is printed to the console
# and the text in the label changes. 

from ECGUI import *

# prints out a message to the console telling us the hello button was clicked
# changes the text in the label to say the hello button was clicked and sets its
# background to green
def hello_clicked():
    print("in hello_clicked")
    change_label(label, "in hello function", bg_color="green")

# prints out a message to the console telling us the world button was clicked
# changes the text in the label to say the world button was clicked 
def world_clicked():
    print("world")
    change_label(label, "clicked")

# creates the whole window with a green background and a title in the top
# bar of "Hello GUI"
window = make_window("Hello GUI", "green")

# adds a button to the window with the text "hello" on it. The hello_clicked
# function will run when it is clicked 
button_hello = add_button(window, "hello")
button_hello['command'] = hello_clicked

# adds a button to the window with the text "world" on it. The world_clicked
# function will run when it is clicked 
button_world = add_button(window, "world")
button_world['command'] = world_clicked

label = add_label(window, "hello world")

# needed so the GUI will keep paying attention and reacting to button clicks
window.mainloop()
