Bonjour,

Dans une boite de dialogue tkinter, j'ai un champ label et un bouton, Quand je clique sur le bouton, ça ouvre une boite de dialogue de sélection d'un fichier, et je doit mettre à jour le label avec le chemin du fichier sélectionné.
Cette boite de dialogue tkinter s'ouvre quand je clique sur un menu de l'interface principale.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
def br2Box(self):
 
        self.mv = Toplevel()
        self.mv.title('Export mavlink .tlog')
        self.mv.transient() 	        # Réduction popup impossible 
        self.mv.grab_set()		        # Interaction avec fenetre jeu impossible
        self.mv.focus()		        # Focus sur la fenetre popup
 
        file_input = tk.Frame(self.mv, bg='green')
        footer = tk.Frame(self.mv)
 
        self.mv.columnconfigure(0, weight=1) # 100% 
 
        self.mv.rowconfigure(0, weight=1) # 10%
        self.mv.rowconfigure(1, weight=1) # 80%
 
        file_input.grid(row=0, sticky='news')
        footer.grid(row=1)
 
        self.mv.input_path = StringVar()
        self.mv.lbl_fin0 = tk.Label(file_input, text="Fichier .tlog")
        self.mv.lbl_fin0.grid(row=0, column=0, padx=5, pady=5)
        self.mv.lbl_fin = tk.Label(file_input, width=30, textvariable=self.mv.input_path)
        self.mv.lbl_fin.grid(row=0, column=1, padx=5, pady=5)
        self.mv.btn_fin = Button(file_input, text='...', width=5, command=self.fileSelect)
        self.mv.btn_fin.grid(row=0, column=2, padx=5, pady=5)
 
        self.mv.btn_OK = Button(footer, text='OK', width = 10, command=self.mv.destroy)
        self.mv.btn_OK.grid(column=0, row=0, padx=5, pady=5)
        self.mv.btn_Cancel = Button(footer, text='Annuler', width = 10, command=self.mv.destroy)
        self.mv.btn_Cancel.grid(column=1, row=0, padx=5, pady=5)
 
 
    def fileSelect(self):
        f = askopenfilename(title="Ouvrir votre document", \
                            filetypes=[('logfile','.tlog'), ('all files','.*')], \
                            initialdir=os.path.dirname(os.path.abspath(__file__)))
        print(f)
        self.mv.input_path.set(f)
        self.mv.lbl_fin.update_idletasks()
L'instruction print(f) dans la fonction fileSelect() m'affiche bien le chemin du fichier sélectionné, mais le champ label ne se met pas à jour.
Pourquoi?

Merci,
Nico