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


Groups > comp.lang.python > #100222

Re: non-blocking getkey?

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python
Subject Re: non-blocking getkey?
Date Thu, 10 Dec 2015 09:54:26 +0100
Organization A noiseless patient Spider
Lines 54
Message-ID <n4befe$f1k$1@dont-email.me> (permalink)
References <n2hdfn$b1d$1@news2.informatik.uni-stuttgart.de> <n2hfe1$n3l$1@dont-email.me> <n2hkho$d1j$1@news2.informatik.uni-stuttgart.de> <n2hlr7$d1j$2@news2.informatik.uni-stuttgart.de> <n4bd3d$trk$1@news2.informatik.uni-stuttgart.de>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Thu, 10 Dec 2015 08:51:58 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="09360e0ab07672f4bcf79b9f96c5414e"; logging-data="15412"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189L3ve7owSksq7uUe9RxoivMTQg1A4JqY="
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
In-Reply-To <n4bd3d$trk$1@news2.informatik.uni-stuttgart.de>
Cancel-Lock sha1:BZZOPQMgEZ5tPL96UlmiUrXVZK8=
Xref csiph.com comp.lang.python:100222

Show key headers only | View raw


Am 10.12.15 um 09:28 schrieb Ulli Horlacher:
> Ulli Horlacher <framstag@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

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


Thread

non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 08:39 +0000
  Re: non-blocking getkey? Christian Gollwitzer <auriocus@gmx.de> - 2015-11-18 10:14 +0100
    Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 10:39 +0000
      Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 11:01 +0000
        Re: non-blocking getkey? Christian Gollwitzer <auriocus@gmx.de> - 2015-11-18 12:17 +0100
        Re: non-blocking getkey? Terry Reedy <tjreedy@udel.edu> - 2015-11-18 07:26 -0500
          Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 13:06 +0000
            Re: non-blocking getkey? Chris Angelico <rosuav@gmail.com> - 2015-11-19 00:24 +1100
              Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 13:57 +0000
            Re: non-blocking getkey? Steven D'Aprano <steve@pearwood.info> - 2015-11-19 00:38 +1100
              Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 13:51 +0000
                Re: non-blocking getkey? Chris Angelico <rosuav@gmail.com> - 2015-11-19 01:01 +1100
                Re: non-blocking getkey? Jussi Piitulainen <harvesting@makes.invalid> - 2015-11-18 16:13 +0200
        Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 16:50 +0000
          Re: non-blocking getkey? Terry Reedy <tjreedy@udel.edu> - 2015-11-18 12:55 -0500
            Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-19 15:48 +0000
              Re: non-blocking getkey? Michael Torrie <torriem@gmail.com> - 2015-11-19 09:31 -0700
              Re: non-blocking getkey? eryksun <eryksun@gmail.com> - 2015-11-20 02:43 -0600
                Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-23 17:01 +0000
                askopenfilename() (was: Re: non-blocking getkey?) Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-28 10:29 +0000
                Re: askopenfilename() Christian Gollwitzer <auriocus@gmx.de> - 2015-11-28 12:45 +0100
                Re: askopenfilename() Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-28 12:48 +0000
                Re: askopenfilename() Christian Gollwitzer <auriocus@gmx.de> - 2015-11-28 14:34 +0100
                Re: askopenfilename() Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-28 16:45 +0000
                Re: askopenfilename() Laura Creighton <lac@openend.se> - 2015-11-28 17:02 +0100
                Re: askopenfilename() Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-28 16:05 +0000
        Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-10 08:28 +0000
          Re: non-blocking getkey? Christian Gollwitzer <auriocus@gmx.de> - 2015-12-10 09:54 +0100
            Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-10 10:26 +0000
          Re: non-blocking getkey? Christian Gollwitzer <auriocus@gmx.de> - 2015-12-10 09:57 +0100
            Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-10 10:40 +0000
          Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-10 15:52 +0000
    Re: non-blocking getkey? eryksun <eryksun@gmail.com> - 2015-11-18 12:24 -0600

csiph-web