0

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()
  • 1
    Does this answer your question? [How to pass arguments to a Button command in Tkinter?](https://stackoverflow.com/questions/6920302/how-to-pass-arguments-to-a-button-command-in-tkinter) – 001 May 20 '22 at 15:21
  • At least part of the problem is described here: http://stackoverflow.com/q/5767228/7432 – Bryan Oakley May 20 '22 at 15:36
  • the fact is that I want to use Entry.get() in a function that I call in the button command and I think this is why there is a problem. Even with these answer I don't have the solution – Dorian Grousset May 21 '22 at 23:48

0 Answers0