salve ho questo code:
from Tkinter import*
root = Tk()
root.withdraw() #this will hide the main window
import tkFileDialog as tkf
f = tkf.Open().show()
print f
che come si può notare apre la finestra di selezione dei file in windows... ma a me serve abilitare il multiselect, per poter caricare più file contemporaneamente come devo fare ?
premetto che sono alle prime armi con Python, ho trovato questo code nel web ma non riesco a farlo funzionare ...
import lwsdk, Tkinter, tkFileDialog, re
contentDir = lwsdk.LWDirInfoFunc(lwsdk.LWFTYPE_CONTENT)
Tkinter.Tk().withdraw() # this hides the Tk window.
result = tkFileDialog.askopenfilenames(title="Choose file(s).", initialdir=contentDir)
if type(result) != 'tuple': # convert the string into separate filepaths.
c = result[:2]
P1 = c + ".*? (?=" + c + ")"
P2 = c + ".*?(?=$)"
P = re.compile(P1 + "|" + P2)
filepaths = re.findall(P, result)
else:
filepaths = result
for f in filepaths:
print f
perchè mi manca la libreria (lwsdk) e non so come poterla installare, ora chiedo come posso fare per abilitare il multiselect, esiste un metodo universale ? senza caricare librerie strane ?