I came up with this solution to a question that I posted on stackoverflow. It uses Tkinter to create a file select dialog window and raise it to the topmost position from jupyter notebook.


1) Is there some kind of built in or canonical way to do this in jupyter notebook that I've missed in my searches?

2) Is there any redundancy?

from tkinter import*
# Create Tk root
root = Tk()
# Hide the main window
root.call('wm', 'attributes', '.', '-topmost', True)

from tkinter import filedialog
infiles = filedialog.askopenfilename(multiple=True)

%gui tk
  • \$\begingroup\$ Why do you want fewer lines? Readability and maintainability should trump lines of code. \$\endgroup\$
    – Mast
    Mar 4, 2017 at 19:04
  • \$\begingroup\$ @Mast agreed. I should rephrase that to say: is there any redundant code. \$\endgroup\$ Mar 4, 2017 at 19:09


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.