import sys
from tkinter import *
def run_GUI():
    # create the window
    root = Tk()
    frame = Frame(root)
    frame.pack()
    #modify root window
    root.title("Simple GUI")
    root.geometry("700x300") # w x h        
    def SP2T():     # Edit occurs here where I forgot to pit that the button was created in a called funtction
        #Creates Row
        frameSP2T = Frame(root)
        frameSP2T.pack(side = TOP)
        #Creating Buttons First Row
        button1 = Button(frameSP2T, padx=13, pady = 6, bd=4, text="SW02",fg = "black", command = SW02)
        button1.pack(side = LEFT)
    def SW02():
        print("SW02 is on")
        button1["fg"] = "green"
    #Sets up initial boot screen
    #Creates Row
    topframe = Frame(root)
    topframe.pack(side = TOP)
    #Creating Buttons First Row
    buttonA = Button(topframe, padx=13, pady = 6, bd=4, text="SP2T",fg = "black", command = SP2T)
    buttonA.pack(side = LEFT)
    buttonB = Button(topframe, padx=12, pady = 6, bd=4, text="SP4T",fg = "black")
    buttonB.pack(side = LEFT)
    buttonC = Button(topframe, padx=12, pady = 6, bd=4, text="SP12T",fg = "black")
    buttonC.pack(side = LEFT)
    buttonD = Button(topframe, padx=12, pady = 6, bd=4, text="QUIT", fg="red",command=frame.quit)
    buttonD.pack(side = LEFT)
    #Kick off event loop
    root.mainloop()
    return
run_GUI()
And I got the error:
Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1487, in __call__
   return self.func(*args)
   File "C:\Python34\gui_attempt.py", line 25, in SW02
   button1["fg"] = "green"
NameError: name 'button1' is not defined
Updated version which hopefully shows the whole picture
There's more to this program so that's why it says line 60, but this is the problem area. I'm trying to change the button's color when pressed.
 
     
     
    