Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get directory path in HTML on localhost with python eel?

I am creating a GUI application that requires the path to folder that user selects. I am using eel library of python to achieve the GUI with HTML, CSS and JS. I just want the path to the folder, I don't want the files in that folder to be uploaded.

Any Solutions ?

like image 602
paritosh batish Avatar asked Sep 14 '25 21:09

paritosh batish


1 Answers

So I found a work around with tkinter and may help others.

in my python I expose a tkinter function to open directories and choose a folder

import tkinter 
import tkinter.filedialog as filedialog

@eel.expose
def selectFolder():
    print("Here")
    root = tkinter.Tk()
    root.attributes("-topmost", True)
    root.withdraw()
    directory_path = filedialog.askdirectory()
    print(directory_path)

in my HTML

<button class="items" onclick="select()">Choose folder</button>

in my JS I am just calling selectFolder() function from python.

function select(){
  eel.selectFolder();
}
like image 185
paritosh batish Avatar answered Sep 17 '25 13:09

paritosh batish