Python2.3 tkFileDialog.askopenfilename returns tuple on Cancel

T

Tim Williams

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 when I
select Cancel.

Python 2.2:

Python 2.2.2 (#3, Jan 21 2003, 08:39:06)
[GCC 2.95.3 20010315 (release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.<type 'str'>


Python 2.3:

Python 2.3 (#1, Aug 4 2003, 10:43:11)
[GCC 3.2 20020903 (Red Hat Linux 8.0 3.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.<type 'tuple'>

Both versions return a string when I select an actual file. Sometimes
I want to click 'Cancel' when I want to bring up my GUI anyway and
select the file later.

I got around this by just putting in an

if not filename: filename='.'

after my call to askopenfilename().

Is this a bug or a feature?

Thanks.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top