tkFileDialog

  • Thread starter Gheorghe Postelnicu
  • Start date
G

Gheorghe Postelnicu

In our example, try replacing the last line with

print file.name

---------- Forwarded message ----------
From: (e-mail address removed)
To: (e-mail address removed)
Date: 8 Nov 2006 11:01:08 -0800
Subject: Problem getting a file pathname with tkFileDialog
Hello,
I am working on a school project that requires me to get the path of a
filename for future treatment.
I've tried getting a file with tkFileDialog.askopenfile.


********************************************
import tkFileDialog
file = tkFileDialog.askopenfile()
print file
********************************************


It prints the opened files stuff, but I just can not find how to get
that path as a string. I've searched around google and the present
group, and found no documentation on the file class used with
tkFileDialog. Does someone have a solution for that?

Thank you

Christian
 
J

James Stroud

Gheorghe said:
---------- Forwarded message ----------
From: (e-mail address removed)
To: (e-mail address removed)
********************************************
import tkFileDialog
file = tkFileDialog.askopenfile()
print file
********************************************

Its ill-advised to assign to built in types (e.g. "file").
It prints the opened files stuff, but I just can not find how to get
that path as a string. I've searched around google and the present
group, and found no documentation on the file class used with
tkFileDialog. Does someone have a solution for that?

import tkFileDialog
afile = tkFileDialog.askopenfile()
print afile.name

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,631
Members
45,338
Latest member
41Pearline46

Latest Threads

Top