[Tutor] Tkinter dialog boxes

Alfred Milgrom fredm at smartypantsco.com
Thu Apr 15 01:26:09 EDT 2004

At 10:59 PM 14/04/04 -0400, David Talaga wrote:
>Does anyone know how to create a dialog box to open a file in Python.  My
>guess would be there has got to be some kind of way! Any help you be greatly
>David Talaga
>dtalaga at novodynamics.com

Tkinter has built-in facilities for this. What about:

from Tkinter import *
import tkFileDialog

top = Tk()
initDir = 'C:/windows/desktop'
filetype = [('Text files', 'txt')]
FileName = tkFileDialog.askopenfilename(initialdir=initDir, filetypes=filetype)
print FileName

Hope this helps,
Alfred Milgrom

More information about the Tutor mailing list