tk - askopenfilenames parsing

D

daku9999

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
 

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

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top