In a jupyter notebook I'd like to use html/javascipt for a file selection dialog instead of tkinter. After some messing around I was able to get this to work and even make the result available to the python kernel. BUT, now I think I see why no one else does this... javascript is not aware of the full path to these files.
I was quite proud of this (inside of a jupyter cell):
%%html
<input type="file" accept=".dat" id="files" name="files[]" multiple />
<output id="list"></output>
<script>
function handleFileSelect(evt) {
var files = evt.target.files;
var output = [];
IPython.notebook.kernel.execute("lstFiles=[]");
for (var i = 0, f; f = files[i]; i++) {
IPython.notebook.kernel.execute("lstFiles.append('" + f.name + "')");
output.push('<li><strong>', f.name, '</strong></li>');
}
document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
</script>
then in another cell...
print(lstFiles)
This gets me the list of files, but not the path. Is there any trick to getting the path? Or even the browser's last used location?