tkinter file selector

Eric Brunel eric.brunel at pragmadev.com
Tue Jan 14 06:17:01 EST 2003


Natacha wrote:
> thanks, but we would like to have the directory in the "Entry" when we
> select a file example :
> _______________________________________           _____________________
> C:/WINDOWS/Bureau/question.doc        |           |     PARCOURIR      |
> ______________________________________|           |____________________|
> 

Just put it there yourself:

---------------------------------
from Tkinter import *
from tkFileDialog import askopenfilename

root = Tk()

fileVar = StringVar()

def browseFile(*whatever):
  fileName = askopenfilename()
  if fileName == '': return
  fileVar.set(fileName)

e = Entry(root, textvariable=fileVar)
e.pack(side=LEFT)
b = Button(root, text='Parcourir...', command=browseFile)
b.pack(side=LEFT)

root.mainloop()
---------------------------------

There's no simpler way to do it.

HTH. Bon courage!
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com




More information about the Python-list mailing list