Command from messagebox won't work

I have a function to delete a selected row from a tkinter’s treeview window that work isolated from the code of my script.
But, when I put this inside the rest of the code, it won’t works as it would do. It just delete the record from the treeview but not from the csv file.

The function is this:

def elimina():
        selezione = tree_colonne.selection()
        ogg = tree_colonne.item(selezione, option='values')
        mb_canc = messagebox.askokcancel(
            title = "Conferma di cancellazione",
            message = "Si vuole confermare l'eliminazione di " + str(ogg))

        if mb_canc == False:

        elif messagebox.askokcancel(
            title = "Conferma di cancellazione",
            message = str(ogg) + " sta per essere eliminato definitivamente. Si è sicuri di procedere?"):

            with open(r'/path/to/file.csv', 'w',
                    newline='', encoding='UTF-8') as elenco_aggiornato:
                scrit = csv.writer(elenco_aggiornato)
                for iid in tree_colonne.get_children():
                    row = tree_colonne.item(iid, option='values')

            messagebox.showinfo(title = "Eliminazione",
                                message = "Se hai sbagliato, cavoli tuoi! \w/")

No errors raises from the IDE.
Is there a sort of TopLevel for tkinter’s messagebox? I didn’t find nothing in the messagebox documentation.

Thanks in advance.

Hey Emanuele I was trying to get the hang of the code implementation… if csv is not being updated accordingly why dont you refresh the the DB(csv in this case) with the data on the treeview everytime you delete. Think of it this way if you can add/insert successfully data the first time, then can you approach it the same way like the current data on the treeview after deletion can refresh the csv… there is definitely a better way but meanwhile…

Thank you for your response.
Finally I found the mistake that was causing that behaviour (a so silly mistake that I’m too ashamed to write here! :sweat_smile:).
Anyway, if you can suggest an example of code to do what you said, please post here.

Hey writing code will be too much of a hassle right now am quite engaged rynna… nywy post the discovery we also learn… There is no shame in the game,

My mistake was just a incorrect path to the file I have to edit.
Anyway, according about what you have suggested, I tried to find in the past some " refresh " method but I didn’t find anything.
Someone on this forum suggested to rewrite the whole csv file to get a simple solution.
That’s why I asked to you to post some example of code about refreshing file if you know how do it. I’m quite ignorant and I try to learn to code in my day off. I often check the official documentation and tutorial but a lot of time finding the right name of a function takes long time and internet could be both an help than a real jungle to find stuff, either if it’s too technical for a newbie.