Am 10.12.15 um 09:28 schrieb Ulli Horlacher:
Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote:
Found it:
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw()
file = askopenfilename()
My users do not like it :-(
They want to drag&drop files.
Therefore I have added it as another option to enter files:
[f] select a file
[d] select a directory
[e] enter a file or directory (with drag&drop or copy&paste)
Well I know that you won't take my advice but.....
There are standard protocols for drag'n'drop of files and folders on all
three major platforms. Tk supports this using the optional TkDND module,
which unfortunately isn't installed with a standard Python distribution.
Beware there is a "Tkdnd" Python module which implements local
Drag'n'drop only; you need the "real thing" from here
http://sourceforge.net/projects/tkdnd/
plus the correct Python bindings: Maybe this is the correct one:
http://osdir.com/ml/python.tkinter/2005-07/msg00000.html
I'm not sure - never used it from Python, only from Tcl. Using "the real
thing" also allows you to accept multiple files/drectories dragged from
the system file manager. Of course, you need a Tk main window to
implement this, which you refused earlier.
With [f] starts askopenfilename and [d] starts askdirectory
The problem with [e] is: my users do not press ENTER after pasting.
My idea now is: instead of raw_input() I use a get_paste() function, which
reads input character for input character and after a (say) 1 s timeout it
returns the string. Pasting a string with the mouse is rather fast, there
should be no big delay between the characters.
How can I implement such a get_paste() function?
I need a non-blocking getkey() function.
It must work on Windows and Linux.
Raw tty input. You'll have to write two different versions for Windows
and Linux. Sorry I can't help with that one.
Christian
--
https://mail.python.org/mailman/listinfo/python-list