Am 16.12.15 um 14:18 schrieb Ulli Horlacher:
Is there an alternative to Tk's askopenfilename() and askdirectory()?
I want to select a files and directories within one widget, but
askopenfilename() let me only select files and askdirectory() let me only
select directories.
Tk calls out into the native file manager to perform the file/open
operation (on Win&Mac, on Unix it brings it's own). Unfortunately, these
dialogs do not have an option to select both directories and files. This
means you would have to do your own. You wouldn't need to start from
scratch, however - Schelte Bron has created a very nice dialog as a
replacement for the (oldfashioned, dull) standard dialog in Tk:
http://wiki.tcl.tk/15897
It would be feasible to tweak it a bit to allow for directory and file
selection. It is written in Tcl, however, but that is not a problem in
itself, you could call it from Python in a similar way that
tk_getOpenFile is implemented.
Concerning your drag&drop problem, it is only possible if you go for a
Tk main window, then you could use TkDND. It is not in the standard
install, but it can be bundled *without installation*, because Tcl
extensions use a mechanism called stubs, which ensures broad binary
compatibility. The only drawback: you will not have a single .py file,
but since on Windows you deliver using pyinstaller, that should not be
an issue.
Christian
--
https://mail.python.org/mailman/listinfo/python-list