473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

tkFileDialog

In our example, try replacing the last line with

print file.name

---------- Forwarded message ----------
From: cd*******@hotmail.com
To: py*********@python.org
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


--
Gheorghe Postelnicu, PhD
MGH, Harvard Medical School
Nov 8 '06 #1
1 3248
Gheorghe Postelnicu wrote:
---------- Forwarded message ----------
From: cd*******@hotmail.com
To: py*********@python.org
********************************************
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/
Nov 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stephen Boulet | last post by:
I'm using the following code to get a file name: import tkFileDialog tkFileDialog.askopenfilename(filetypes=) How can I do this without an empty tk window popping up and hanging around after...
0
by: Tim Williams | last post by:
I just installed Python 2.3 on my Redhat system. When I tried to run one of my programs that use tkFileDialog.askopenfilename(), I got an error because it returns a tuple instead of a null string...
3
by: Tim Williams | last post by:
Hi. I'm using Python 2.3 and trying to use tkFileDialog to get a list of files. I get a message about the '-multiple' option is not a valid option in the call to Open. Python 2.3 (#1, Aug ...
2
by: Tim Williams | last post by:
I'm using Python 2.3.2 and tkFileDialog in a program I have. I'm trying to use this on Linux (RH 8.0) and Windows 2000. When I first upgraded from v2.2 to v2.3. I noticed that...
2
by: Read Roberts | last post by:
I have the current Windows binary install of Python 2.3.4 on my Windows XP system. I am pained to discover that tkFileDialog.askdirectory() returns a mangled path when a directory is selected...
3
by: jaime.suarez | last post by:
I am creating a very simple GUI with one Entry widget and one Button. The purpose of the Button widget is to Browse for a file using tkFileDialog.askopenfilename(). I bind the button to a...
9
by: cdroulers | last post by:
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. ...
2
by: Traclo | last post by:
Hello all! I have a problem concerning tkFileDialog. When I use the the askopenfilename command to open a text file it opens a tkinter window (apart from the file browsing window) which refuses to...
0
by: Matthias Huening | last post by:
Hi, I have problems using tkFileDialog under Linux (Ubuntu 8.04 in my case, but other Linuxes seem to show the same behaviour). The following works fine: import tkFileDialog f =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.