Here's my problem: There's a database of addresses for companies - if you try to create an invoice and the address for it is missing it creates the pop up prompting entering the address. However once that's done the rest of the code is never executed. Not sure if it's got something to do with the new window or the try/except statement.
def addPopUp(table):
    def popClose():
        print("closing")
        popup2.destroy()
    def addAddress(table, address):
        file = open('addresses.csv', 'a')
        file.write("\n{},{}".format(table[3], address))
        file.close()
        popup2.destroy()
    popup2 = Tk()
    popup2.wm_title("Add address")
    label = Label(popup2, text="Address needed for {}".format(table[3]))
    label.grid(row=0, column=0, columnspan=3)
    newAdd = Entry(popup2)
    newAdd.grid(row=1, column=0, columnspan=3,)
    addBut = Button(popup2, text="Add", command= lambda:addAddress(table,newAdd.get()))
    addBut.grid(row=2,column=0)
    cancel = Button(popup2, text="Cancel",command = popClose)
    cancel.grid(row=2, column=2)
    popup2.mainloop()
def generateInvoice():
        print("Generating invoice")
        sel = invoices.selection()
        if  sel == ():
            print("You need to select a line")
            return
        line = int(sel[0][1::])-1
        global addresses
        if True:
            try:
                addresses[invoiceData[line][3]] == None
            except:
                addPopUp(invoiceData[line])
        # THIS CODE NEVER HAPPENS IF THERE'S AN EXCEPTION vvvvvvvv
                addresses = loadAddresses()
        def addPO():
            newPO = poNum.get()
            if newPO != "":
                print(invoiceData[line])
                invoiceData[line].pop(7)
                invoiceData[line].insert(7,newPO)
                print(invoiceData[line])
            popup.destroy()
            createPdf(invoiceData[line],addresses)
        def notNeeded():
            popup.destroy()
            createPdf(invoiceData[line],addresses)
        def popClose():
            print("closing")
            popup.destroy
        if invoiceData[line][7]=='':
            popup = Tk()
            popup.wm_title("PO needed?")
            label = Label(popup,text = "Add PO")
            label.grid(row=0,column=0,columnspan = 3)
            poNum = Entry(popup)
            poNum.grid(row=1,column=0,columnspan = 3)
            addBut = Button(popup, text = "Add", command=addPO)
            noNeed = Button(popup,text = "Not needed", comman=notNeeded)
            addBut.grid(row=2,column=0)
            noNeed.grid(row=2,column=1)
            cancel = Button(popup,text = "Cancel", command=popClose)
            cancel.grid(row=2,column=2)
            popup.mainloop()
        else:
            createPdf(invoiceData[line],addresses)
 
    