This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: tkFileDialog.askopenfilenames scrambling multiple file selection
Type: behavior Stage:
Components: Tkinter Versions: Python 2.5
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: ned.deily, pfhall
Priority: normal Keywords:

Created on 2010-11-04 20:56 by pfhall, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg120438 - (view) Author: Peter Hall (pfhall) Date: 2010-11-04 20:56
I am running the following :

Linux Centos version 2.6.18
Python version 2.5
tk version 8.5
tcl version 8.5

I have a Python GUI program (importing Tkinter and tkFileDialog)
which prompts the user to select a (one to many) list of file names. 
The code is :

fileList = tkFileDialog.askopenfilenames(initialdir=self.startfiledir,
                                         title="Select Files for Processing",
                                         filetypes=self.ftypes, multiple=1)

where "startfiledir" and "ftypes" are defined elsewhere.
When this code is run a file selection box pops up
listing the chosen directory. Selecting just one file works fine.

To select multiple files the user highlights a selection
of the displayed files by dragging the cursor over them 
with "SHIFT left-mouse-button" pressed. 
It also lists ALL the selected files in the "File names:" selection field
at the bottom of the selection box. These are separated by spaces.
Clicking "Open" results in the selection box program trying to treat
the entire list as a single file name.
IE. It looks for a single file called "/home/mydir/file1 file2 file3 file4".
Since there is no such file an error pop-up box appears with a 
"File ... does not exist." message.

It appears that the file name list is not being parsed into indivdual file names.
I have tried combinations with "askopenfilename" instead of "askopenfilenames"
and including/omitting "multiple=1". 
I have also tried "multiple=bool(1)" and "multiple=xxx"
where "xxx=1" and "xxx=bool(1)".
None of these change the behaviour.

Is there a fault with my code ?
Is this a bug in "tkFileDialog.askopenfilenames" ?
Is there a workaround ?

Suggestions are welcome.
msg120461 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-11-05 00:14
Works for me on a current Debian Linux system with a Debian Python 2.5.5 + Tcl/Tk 8.5 and with Python 2.6.1 + Tcl/Tk 8.5 on OS X 10.6 and with Python 2.7 + Tcl/Tk 8.4 on OS X 10.6. In all cases, the tkFileDialog.askopenfilenames returns a tuple of absolute file paths.  (BTW, only security issues are accepted for Python 2.5 at this time).
msg120702 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-11-08 01:37
Postscript: I've subsequently noticed Issue5712 in which somewhat similar symptoms are reported but, so far, only on Windows systems.  If your problem is not yet resolved, you might want to chime in there.
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54525
2010-11-08 01:37:34ned.deilysetmessages: + msg120702
2010-11-05 00:14:52ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg120461

resolution: works for me
2010-11-04 20:57:03pfhallsettype: behavior
2010-11-04 20:56:05pfhallcreate