tkFileDialog, askopenfiles in v2.6 question

Discussion in 'Python' started by fransstil, Nov 26, 2008.

  1. fransstil

    fransstil Guest

    To select a group of files works fine in 2.5
    ....
    from tkFileDialog import askopenfiles

    fnames = askopenfiles(title = "Select files",
    initialdir = "C:\\temp",
    filetypes=[("All", "*.*")])

    for i in range(len(fnames)):
    fnames = fnames.name
    ...
    return fnames
    ....

    but now 2.6 strange results

    - IOError: [Errno 2] No such file or directory: u'{'

    - ERROR '.name' no longer exists in 2.6

    - If '.name' removed the return of 'askopenfiles' is no longer a list,
    it contains braces for some?! of the directories
    example: {C:/temp/file1.ext} {C:/temp/file2.ext} {C:/temp/file3.ext}

    - askopenfilenames gives the same results

    Can someone gave me a hint

    Thanks in advance

    Frans Stil



    --------------= Posted using GrabIt =----------------
    ------= Binary Usenet downloading made easy =---------
    -= Get GrabIt for free from http://www.shemes.com/ =-
    fransstil, Nov 26, 2008
    #1
    1. Advertising

  2. fransstil

    MRAB Guest

    fransstil wrote:
    > To select a group of files works fine in 2.5
    > ...
    > from tkFileDialog import askopenfiles
    >
    > fnames = askopenfiles(title = "Select files",
    > initialdir = "C:\\temp",
    > filetypes=[("All", "*.*")])
    >
    > for i in range(len(fnames)):
    > fnames = fnames.name
    > ...
    > return fnames
    > ...
    >

    As far as I can see, "tkFileDialog.py" hasn't changed, but it looks like
    one of the modules it uses is 'broken' in some way.

    > but now 2.6 strange results
    >
    > - IOError: [Errno 2] No such file or directory: u'{'
    >

    Internally it's expecting a method to return a list and is then
    iterating through it, but the method is returning a string instead, so
    it's actually iterating through that...

    > - ERROR '.name' no longer exists in 2.6
    >
    > - If '.name' removed the return of 'askopenfiles' is no longer a list,
    > it contains braces for some?! of the directories
    > example: {C:/temp/file1.ext} {C:/temp/file2.ext} {C:/temp/file3.ext}
    >

    This a what is being returned internally and it should be splitting it
    into a list.

    > - askopenfilenames gives the same results
    >
    > Can someone gave me a hint
    >
    > Thanks in advance
    >

    A short-term fix is to use askopenfilenames and split the string
    yourself. It's a space-separated list of paths, each path delimited by
    braces (and a path might contain a space).
    MRAB, Nov 27, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Boulet

    tkFileDialog without a parent window

    Stephen Boulet, Jul 3, 2003, in forum: Python
    Replies:
    2
    Views:
    483
    klappnase
    Jul 20, 2003
  2. tkFileDialog question

    , May 12, 2005, in forum: Python
    Replies:
    3
    Views:
    397
  3. Matt Mitchell

    tkFileDialog question

    Matt Mitchell, Nov 13, 2009, in forum: Python
    Replies:
    4
    Views:
    359
    Matt Mitchell
    Nov 16, 2009
  4. Matt Mitchell

    RE: tkFileDialog question

    Matt Mitchell, Nov 13, 2009, in forum: Python
    Replies:
    1
    Views:
    471
  5. garyr

    tkFileDialog Question

    garyr, Mar 16, 2011, in forum: Python
    Replies:
    0
    Views:
    232
    garyr
    Mar 16, 2011
Loading...

Share This Page