Choosing a file in Python with simple Dialog Choosing a file in Python with simple Dialog python python

Choosing a file in Python with simple Dialog


How about using tkinter?

from Tkinter import Tk     # from tkinter import Tk for Python 3.xfrom tkinter.filedialog import askopenfilenameTk().withdraw() # we don't want a full GUI, so keep the root window from appearingfilename = askopenfilename() # show an "Open" dialog box and return the path to the selected fileprint(filename)

Done!


Python 3.x version of Etaoin's answer for completeness:

from tkinter.filedialog import askopenfilenamefilename = askopenfilename()


With EasyGui:

import easyguiprint(easygui.fileopenbox())

To install:

pip install easygui

Demo:

import easyguieasygui.egdemo()