Entry
Can you make tkFileDialog (File Open) Select Multiple Files? If so, how?
Oct 11th, 2002 07:30
Martin Franklin, TomH, Mark Paschal, Arlo Valles, http://tcl.activestate.com/man/tcl8.3/TkCmd/getOpenFile.htm http://tcl.activestate.com/man/tcl8.2.3/TkCmd/getOpenFile.htm
Support for multiple file selection was added to the underlying
Tcl/Tk
widget in Tcl 8.3, but Tkinter doesn't appear to allow it in Python
2.2
(that is, attempting to pass the option causes a TclError anyway).
As of Tcl 8.4 this option is available to all platforms. Tcl 8.3
was restricted to Mac only.
You can always use the Pythonwin win32ui module, but this is rather
a
sledgehammer to crack a nut.
dlg = win32ui.CreateFileDialog(1, '.zip', None
,HIDEREADONLY|win32con.OFN_OVERWRITEPROMPT|win32con.OFN_ALLOWMULTISELECT
, 'all files (*.*)|*.*||'
)
dlg.SetOFNTitle('Select files to add...')
dlg.SetOFNInitialDir('C:\\')
rc = dlg.DoModal()
if rc == 1:
for f in dlg.GetPathNames():
doStuffWithPathname(f)
Also, if the app has a console window, then after the file open
dialog
is closed, the app window is behind the console window. I have made
some lame attempts to fix this, but had no success. I would
appreciate
anyone giving me a solution.