faqts : Computers : Programming : Languages : Python : Tkinter

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 12 people (58%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

how would i make something that asked for a directory and saved it as a variable?

Nov 6th, 2002 23:03
John Withers, chase cobb,


i saw someone ask this so here it is. its so simple its really not 
worth typing, but you have to start somewhere


import os

x = raw_input("Enter your Directory")

print x

---

Since this is in the Tk area, it is highly unlikely this is what was
intended. While technically correct, I suspect what the supplicant
actually wanted was:

from tkFileDialog import *
dir = askdirectory()
print dir


Note this will only work with Tk 8.3+ and I have read that it won't work
prior to Py 2.2, but I don't know that for sure, since I have just had
cause to use it recently and didn't use it with earlier versions.