I have a simple script which parses an excel file and does some data analysis on it’s contents and reports it as a html output. I don’t need a UI, but right now I’m prompting the user for the file to parse using raw_input which is very inconvenient. So needed to find a quick and easy way to present a file selection dialog to the user with which they can select the excel file.
Here’s the super convenient and simple way to get a minimal file selection GUI from standard python modules.
import Tkinter,tkFileDialog root = Tkinter.Tk() root.withdraw() filename = tkFileDialog.askopenfile(parent=root,mode='r',filetypes=[(“Excel file”,”*.xls”)],title='Choose an excel file') if filename != None: print “This excel file has been selected”, file
And here’s a good presentation on Tkinter titled “Tkinter Does Not Suck”. I agree…