I want that when the user write something and then click on the button. The click trigger the save of an image, but save it with the entry that the user decided. The probleme is that this function save the file before I click on something and with empty name. I don't find the problem and there isn't any error because the process is working but badly.
from tkinter import *
import os
import shutil
cible="C:/Users/GROUSD01/Desktop/ProjetEntremont/DossierCible/96P23681.xlsx"
archive="C:/Users/GROUSD01/Desktop/ProjetEntremont/DossierArchive/"
window = Tk()
window.title("Enregistrement de la photo")
window.geometry("360x120")
window_title = Label(window, text="Veuillez saisir l'identifiant de la longe pour le suivi PE :",font=("Courrier", 7))
nom_entry = Entry(window)
#function that make the save
def save_photo(doss_cible,doss_archive):
source= doss_cible
destination= os.path.join(doss_archive, nom_entry.get()+".xlsx" )
shutil.copyfile(source, destination)
window_bouton=Button(window,text="Enregistrer la photo",command=save_photo(cible,archive))
window_title.pack()
nom_entry.pack()
window_bouton.pack()
window.mainloop()