below is my code for a GUI that I am writing. It has taken me a very long time to get to this point being new to Python. My dilemma: I after clicking the select file button I can browse through the windows file explorer and then select a file. I would like the file path to populate into the entry_widget after clicking open in the windows file explorer. Any guidance would be greatly appreciated.
from tkinter import *
from tkinter import filedialog
#Defining all sub-routines. Must be directly after import.
def selectfile():
filename = filedialog.askopenfilename()
#Make the GUI.
root = Tk()
#Inserting a title for the dialog window.
root.title("Duplicate Files Tool")
#Adjusting the geometry of window to fit the title of the dialog window.
root.geometry('800x500')
#Setting the background color.
root.configure(bg='#004400')
#Adding a frame for widgets.
ButtonFrame1=Frame(root, bg='#004400')
ButtonFrame1.grid(row=1, column=0, padx=20, pady=5)
#Creating buttons for GUI interface.
Button(ButtonFrame1, text="Select A File Folder", command=selectfile, fg="blue").grid(row=1, column=0, pady=5)
Button(ButtonFrame1, text="Select A File Folder", command=selectfile, fg="blue").grid(row=2, column=0, pady=5)
Button(ButtonFrame1, text="Select Output", command=selectfile, fg="blue").grid(row=3, column=0, pady=5, sticky=W)
Button(ButtonFrame1, text="Run Tool", fg="blue").grid(row=4, column=0, pady=5, sticky=W)
#Adding entry field.
entry_field1 = Entry(ButtonFrame1, width=100, borderwidth=2).grid(row=1, column=1, padx=10, pady=5)
entry_field2 = Entry(ButtonFrame1, width=100, borderwidth=2).grid(row=2, column=1, padx=10, pady=5)
entry_field3 = Entry(ButtonFrame1, width=100, borderwidth=2).grid(row=3, column=1, padx=10, pady=5)
#EVERYTHING GOES ABOVE THIS LINE!!!
#This keeps the pop-up window/tool from closing. Creates infinite loop so window stays open.
root.mainloop()
#Notes
#.pack() throws your label or box anywhere into the data frame.