Drag-and-Drop multiple files in Python (Windows) Drag-and-Drop multiple files in Python (Windows) tkinter tkinter

Drag-and-Drop multiple files in Python (Windows)


It seems that filenames containing whitespace are being wrapped in braces(Tcl list style). To get a usable filelist, you should be able to dosomething like:

import Tkinterfrom untested_tkdnd_wrapper import TkDNDdef handle(event):    files = root.tk.splitlist(event.data)    for filename in files:        event.widget.insert('end', filename)root = Tkinter.Tk()    lb   = Tkinter.Listbox(root, width=50)lb.pack(fill='both', expand=1)dnd = TkDND(root)dnd.bindtarget(lb, handle, 'text/uri-list')root.mainloop()


Just use the tkinter file dialog, then just have it insert the files into the entry box.

Example:

filedialog = tkFileDialog.askopenfilenames(*options*)entry.insert(END, filedialog)

Example Using StringVar:

entryVar = StringVar()entry = Entry(textvariable=entryVar)filedialog = tkFileDialog.askopenfilenames(*options*)entryVar.set(filedialog

Hope this helps!