I'm trying the implement the browse functionality in Tkinter, I'm able to implement the browse file option, however, after selecting the file at a particular location it's displaying file location on the console, how to print that location on the label? At the following place, file_location or file_name should be printed.
entry_1.insert(0, 'File_location')
For e.g. the file location is
Path with file name C:\Users\Desktop\test\test.txt
, so this file location should be printed on the label instead of the console.
And along with that, if I want only a path without a file name then how it can be done?
Path without file name. C:\Users\Desktop\test
What extra functionality do I need to add in order to implement this feature? Any help would be appreciated.
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from io import StringIO
import sys
import os
root = Tk()
root.geometry('700x650')
root.title("Data Form")
def file_opener():
input = filedialog.askopenfiles(initialdir="/")
print(input)
for i in input:
print(i)
label_1 = Label(root, text="Location",width=20,font=("bold", 10))
label_1.place(x=65,y=130)
x= Button(root, text='Browse',command=file_opener,width=6,bg='gray',fg='white')
x.place(x=575,y=130)
entry_1 = Entry(root)
entry_1.place(x=240,y=130,height=20, width=300)
entry_1.insert(0, 'File_location')
root.mainloop()