Search code examples
pythontkinterglob

Taking Tkinter Entry to fill in glob pathname


would like some help with this little issue.

I am trying to make a GUI interface where the user enters the folder name and the file name. Those values then get fed into glob function. I have set it up as below.

file_name = Entry(root)
folder_name = Entry(root)

I know that if I do the following, it will never work because they are in quotation marks.

files = glob.glob("folder_name.get()/file_name.get()") 

So how do I get my entries into the glob function?


Solution

  • Use f string in python.

    files = glob.glob(f"{folder_name.get()}/{file_name.get()}")