I created a small program that shows a window and asks passwords, ids, to check if the user is saved in a database. If password is correct, then it affects True to a boolean named mdp_valide ('password_is_valid' in english) which was False before, and destroys the window of connexion. It's a function that changes that value, so I used a global statement at the top of the function. However, when it closes the window, the value mdp_valide is back to False
Here's some code to help you understand
First, the main program that will call the other function:
while 1:
    mdp_valide, utilisateur_en_cours = fenetre_connection(False, None)
    print ('in the main', mdp_valide, utilisateur_en_cours)
    if not mdp_valide:
        sys.exit()
    else :
        lancer_messagerie(utilisateur_en_cours)
Then, the function which is not working:
def fenetre_connection (mdp_val, utilisateur):
    mdp_valide = mdp_val
    utilisateur_en_cours = utilisateur
    root_co = Tk ()
    # .... Lots of stuff
    def verification():
        mdp_co = mot_de_passe.get()
        global mdp_valide
        global utilisateur_en_cours
        if mdp_co == recuperer_donnee_utilisateur (identifiant_utilisateur_co, 'mot_de_passe'): # check if the password is the one of the database
            print ('condition checked')
            mdp_valide = True
            utilisateur_en_cours = identifiant_utilisateur_co
            print ("before destroying : ", mdp_valide, utilisateur_en_cours)
            root_co.destroy()
            print ("after destroying : ", mdp_valide, utilisateur_en_cours)
        else:
            return 1
    Button(Frameboutons_co, text="Valider", font='Cambria', command = verification).pack(side=RIGHT) #Bouton qui verifie la validité du pseudo et du mot de passe
    root_co.mainloop()
    print ('before return : ', mdp_valide)
    return mdp_valide
Test :
before destroying:  True guil23
after destroying :  True guil23
before return :  False None
in the main : False None
The problem is here : the function verification () does change the value of mdp_valide into True, but after returning the value, it's back to False
global mdp_validein the functionfenetre_connection. That might be your problem.