from tkinter import *    # the star means import everything
from tkinter import ttk
from tkinter import font

def initBackground():
    global image1,image2
    global background
    global pic
    
    # read in images
    image1 = PhotoImage(file="highway.gif")
    image2 = PhotoImage(file="Rhododendrum.gif")
    # start with highway background
    background.configure(image=image1)
    pic = "highway"

# Callbacks
# Function to run when arrow button is pushed
def go():
    print("Go!")

# Function to run when center button is pushed
# switch background back and forth
def stop():
    global background
    global pic

    # switch to the other background image
    if pic=="highway":    
        background.configure(image=image2)
        pic = "flower"
    else:
        background.configure(image=image1)
        pic = "highway"
    print("Stop!")

def main():
    global background
    
    # Make the new window
    root = Tk()  # function that makes a window
    root.title("Game controller")

    # Change style to use a big font
    bigFont = font.Font(family='Helvetica', size=20)
    style = ttk.Style()
    style.configure("TButton", font=bigFont) # for buttons
    style.configure("TLabel",font=bigFont) # for labels

    # Put a frame into the window
    # widgets go into frame
    content = ttk.Frame(root,padding=(40,40,40,40)) # belongs in
    # root window, has space around sides. 
    # Fill up whole root window. 
    content.grid(column=0, row=0)


    background = ttk.Label(content)
    initBackground()
    background.grid(column=0, row=0, columnspan=3, rowspan=3)


    # up button
    b0 = ttk.Button(content, text="^",command=go, width="5")
    b0.grid(column=1,row=0)

    # left button, etc
    b1 = ttk.Button(content, text="<",command=go, width="5")
    b1.grid(column=0,row=1)

    b2 = ttk.Button(content, text="o",command=stop, width="5")
    b2.grid(column=1,row=1)

    b3 = ttk.Button(content, text=">",command=go, width="5")
    b3.grid(column=2,row=1)

    b4 = ttk.Button(content, text="v",command=go, width="5")
    b4.grid(column=1,row=2)

    # bring up the user interface we have made
    root.mainloop()

main()
