tk - askopenfilenames parsing

daku9999 at gmail.com daku9999 at gmail.com
Sun Apr 5 19:43:26 EDT 2009


Hello,

I'm having trouble with the output from askopenfilenames...:

---

root = tkinter.Tk()
    root.withdraw()
    files = tkinter.filedialog.askopenfilenames(parent=root,
       title='Choose file(s)')
    if not files:
        tkinter.messagebox.showerror("No input file", "No input file
given")
        sys.exit()
----

I'm using "filenames" because I want to handle the opening and closing
of the files myself.   But I'm having trouble with what 'files' is, as
it appears to be a string with a space between each path/filename
(when choosing multiple files not in the directory that it is run in,
e.g. when I browse to a different directory and grab files).

tryin: for filenames in files.split() works as long as there are no
directories containing spaces in the names (unlikely).

How does one go about parsing the return from askopenfilenames?

I'm just trying to let the user select multiple files for some batch
parsing and then letting the script happily loop through each one.

Any help would be appreciated.

pg



More information about the Python-list mailing list