0
I created a function that opens a file with Tkinter + filedialog, so far so good.
But I need to print the directory of the selected file on a label.
Follows function:
from tkinter import *
from tkinter import filedialog
import pandas as pd
def browse_button2():
df2 = pd.read_csv(filedialog.askopenfile()) #aqui o botão seleciona o arquivo
lb2["text"] = filedialog.askopenfilename() #aqui estou tentando definir que o label receba em sua propriedade "text" como valor a caminho do arquivo selecionado, Exemplo "C:\documentos\texte.csv"
return df2
lb2 = Label(root, font=( 'arial', 10), bd=1, width=43, height=1, relief=RIDGE, borderwidth=1)
lb2.grid(row=2, column=0)
lb2.configure(background='#FFFFFF')
lb2.place(x=48, y=136)
to print the directory I used the following lb2["text"] = filedialog.askopenfilename() it sure prints the file directory, but it opens 2x the dialog to select a file
– Willian De Angelo
I understand, I’m going to try to explain it in a better way. to open the file I am using askopenfile(), which opens me a window to choose the file. I am not discrediting in the code a fixed path to choose the file. when therefore when I use the command of the form you sent me it prints the path of the function "Path" and not the path of the arch I selected
– Willian De Angelo
I think I understand what you want so I’ll edit the answer. Please see if that’s right.
– JeanExtreme002
Very good, that’s right, very much Thank you, I’m new with programming, this is very basic but for those who start sometimes enrroca in silly things
– Willian De Angelo