New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tkinter - askopenfilenames returns string instead of tuple in windows 2.6.1 release #49962
Comments
from tkFileDialog import askopenfilenames
a = askopenfilenames()
print a
print type(a) ''' ---- behaviour seen on windows xp 2.6.1 python release. Linux |
With 2.6.2 on Windows, I get filenames surrounded by {}, all in a (BTW, I don't see *any* unit tests for tkinter :( ) |
This string surrounded by { } indicates it is supposed to be a tcl
It could be, or not. A simple solution would be to call the splitlist
There are some one a separated branch for now, but it doesn't include |
I've written a quick workaround for the issue, where I manually split the filenames and always return a tuple. It might be useful to someone experiencing this problem, so I'm adding it to the issue here. |
Two issues related with the workaround suggested by nosklo.
Any updates on a fix? This bug is really giving me a hard time. |
Update!! I found a very good workaround for this and it works very nicely, with both 2.5 and 2.6 versions. Below is the segment from my code:- from Tkinter import *
import tkFileDialog
master = Tk()
master.withdraw() #hiding tkinter window
Inputfiles = tkFileDialog.askopenfilenames(title="Select the source input file(s)", filetypes=[("mpf file",".mpf"),("All files",".*")])
#Heres the TRICK!
InputfilesList = master.tk.splitlist(Inputfiles) |
UGH! Sorry for that, I mispasted something and didn't notice, since it filled the comment entry box perfectly :( This is the real message I meant to paste: ---------------------------- vijay, The workaround I provided above takes the blank spaces in filepaths thanks in advance |
Hi Clovis Ok, I did not check if your split string function check for spaces or not, sorry for that. In my first post I mentioned this:- "2. We have different versions of Python installed in our Lab machines, some have 2.5 and others got 2.6. If I run the code using the version2.6 workaround on a machine with version2.5, obviously it gives an error!!" Infact I started out using your split string function but it was on a machine with Python2.6. It worked fine. Then I ran the same code on a machine with version Python2.5 and it threw an error when I tried calling your function, because the argument I passed to your function was already a tuple and not a string!! (I hope I could explain without confusing) I would prefer my code to have some level of downward compatibility (to be able to run on Python of lower versions). Thats the reason I prefer to use the 'splitlist' method from Tkinter, as I dont need to change my code for different Python versions. Best Regards |
There seems some similarity between this issue and issue bpo-10316 which occurs on Linux. |
Is it still reproducible on 2.7? |
Answering Serhiy Storchaka's question: Yes it's still reproducible with 2.7.6. |
What are values of Tkinter.wantobjects, Tkinter._support_default_root, Tkinter._default_root, Tkinter._default_root.wantobjects()? Before and after calling tkFileDialog.askopenfilenames(). |
Requested information: Before After |
Thank you Martin. May be this issue was fixed in bpo-19020. |
i had similar issue with python 2.7.. works fine with fix provided by vijay (luckycusp) thanks a lot. |
Som, what is full version of your Python? |
@serhiy Storchaka - its Python 2.7.6 |
This bug was fixed in 2.7.7. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: