from tkinter import *  # Import everything from tkinter to build the GUI window

# Create the main application window
root = Tk()
root.title("Tkinter Button Lesson")  # Set a title for the window

# ─────────────────────────────────────────
# FUNCTIONS
# Always define functions before using them
# ─────────────────────────────────────────


# Define a function that runs when the button is clicked
def click_me():
    # Create a new label and display it in the window
    # This label appears every time the button is clicked
    clickBtn = Label(root, text="It looks like you clicked a button!")
    clickBtn.pack()


# ─────────────────────────────────────────
# WIDGETS
# ─────────────────────────────────────────

# Create and display the main label
# This label is static — it does not change
myLabel = Label(root, text="Tkinter Label")
myLabel.pack()  # Add the label to the window

# Create a button with red text and a white background
# command=click_me means clicking this button will call the click_me() function
myButton = Button(root, text="Click Me!", fg="red", bg="white", command=click_me)
myButton.pack()  # Add the button to the window

# ─────────────────────────────────────────
# MAIN LOOP
# Keeps the window open and waiting for
# user actions like button clicks.
# Nothing below this line will ever run.
# ─────────────────────────────────────────
root.mainloop()
