This is my code. All it does is open a window and have a blue button with the word "ice" on it. Once you click the "ice" button, it opens a second window and is supposed to close the second window. But I cant seem to get that to work.
from tkinter import *
import tkinter.messagebox
import os.path        
def main():
    #opening first window
    top=Tk()
    #changing window size, color, and name
    top.configure(bg="#AED6F1")
    top.geometry("800x600+300+80")
    top.title()
    #Button to get login screen
    Button_1 =   Button(top,text="Ice",
                        bg="#AED6F1",relief=FLAT,
                        bd=0,font="Times 
                        100 bold",command=secondary)
    Button_1.place(x=0,y=0)
    top.mainloop()
def secondary():
    top.destroy()
main()
It just gives the error:
return self.func(*args) File "E:\Programing\test\Eise.py", line 21, in secondary top.destroy() NameError: name 'top' is not defined
What do I need to add to get this to work?
 
     
    