Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100585

Re: Tk alternative to askopenfilename and askdirectory?

From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python
Subject Re: Tk alternative to askopenfilename and askdirectory?
Date 2015-12-18 09:32 +0100
Organization A noiseless patient Spider
Message-ID <n50g6o$g4n$1@dont-email.me> (permalink)
References <n4robu$9bs$1@news2.informatik.uni-stuttgart.de>

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Tk alternative to askopenfilename and askdirectory? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-16 13:18 +0000
  Re: Tk alternative to askopenfilename and askdirectory? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-12-16 09:18 -0500
  Re: Tk alternative to askopenfilename and askdirectory? Lorenzo Sutton <lorenzofsutton@gmail.com> - 2015-12-16 17:24 +0100
    Re: Tk alternative to askopenfilename and askdirectory? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-16 17:08 +0000
  Re: Tk alternative to askopenfilename and askdirectory? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-12-16 16:28 -0800
    Re: Tk alternative to askopenfilename and askdirectory? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-17 14:14 +0000
  Re: Tk alternative to askopenfilename and askdirectory? Christian Gollwitzer <auriocus@gmx.de> - 2015-12-18 09:32 +0100
    Re: Tk alternative to askopenfilename and askdirectory? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-18 09:27 +0000

csiph-web