4
\$\begingroup\$

Background

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.

Questions

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.withdraw()
root.call('wm', 'attributes', '.', '-topmost', True)

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.