Re: getkey

2016-01-16 Thread Ulli Horlacher
Ulli Horlacher wrote: > The first byte of an escape sequence (example: ^[[21~ for F10) is > recognized, but the trailing bytes then are not discarded by > clear_keyboard_buffer() and get_key() returns the second byte of the > escape sequence. I have found a solution: def clear_keyboard_buffer()

getkey

2016-01-16 Thread Ulli Horlacher
I have an application which runs on Windows and UNIX where I need to get one keypress from the user (without ENTER). Keys which sends escape sequences (e.g. cursor or function keys) should be ignored. I have a solution for Windows, but not for UNIX: The first byte of an escape sequence (example:

Re: non-blocking getkey?

2015-12-10 Thread Ulli Horlacher
between the characters. > > How can I implement such a get_paste() function? > I need a non-blocking getkey() function. I found a solution for Windows: print("\nCopy&paste a filename or drag&drop a file into this window") file = get_paste() print('\n"%s

Re: non-blocking getkey?

2015-12-10 Thread Ulli Horlacher
Christian Gollwitzer wrote: > Another cheap solution comes to mind: On windows, dropping files onto an > icon on the desktop is interpreted as "launch the program with > additional arguments", where the arguments are the file names. Ohhh... great! This helps me a lot! > Maybe you could try i

Re: non-blocking getkey?

2015-12-10 Thread Ulli Horlacher
Christian Gollwitzer wrote: > > 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) >

Re: non-blocking getkey?

2015-12-10 Thread Christian Gollwitzer
Am 10.12.15 um 09:28 schrieb Ulli Horlacher: Ulli Horlacher wrote: My users do not like it :-( They want to drag&drop files. Another cheap solution comes to mind: On windows, dropping files onto an icon on the desktop is interpreted as "launch the program with additional arguments", where th

Re: non-blocking getkey?

2015-12-10 Thread Christian Gollwitzer
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 s

Re: non-blocking getkey?

2015-12-10 Thread Ulli Horlacher
. 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. -- Ullrich Horlacher Server und Virtualisierung Rechenze

askopenfilename() (was: Re: non-blocking getkey?)

2015-11-28 Thread Ulli Horlacher
Ulli Horlacher wrote: > eryksun wrote: > > On Thu, Nov 19, 2015 at 10:31 AM, Michael Torrie wrote: > > > One windows it might be possible to use the win32 api to enumerate the > > > windows, find your console window and switch to it. > > > > You can call GetConsoleWindow [1] and then SetForegro

Re: non-blocking getkey?

2015-11-23 Thread Ulli Horlacher
eryksun wrote: > On Thu, Nov 19, 2015 at 10:31 AM, Michael Torrie wrote: > > One windows it might be possible to use the win32 api to enumerate the > > windows, find your console window and switch to it. > > You can call GetConsoleWindow [1] and then SetForegroundWindow [2]. (...) Sorry, for th

Re: non-blocking getkey?

2015-11-20 Thread eryksun
On Thu, Nov 19, 2015 at 10:31 AM, Michael Torrie wrote: > One windows it might be possible to use the win32 api to enumerate the > windows, find your console window and switch to it. You can call GetConsoleWindow [1] and then SetForegroundWindow [2]. import os import sys try:

Re: non-blocking getkey?

2015-11-19 Thread Michael Torrie
On 11/19/2015 08:48 AM, Ulli Horlacher wrote: > > The focus is moved to another, unrelated window, but not back to the > window in which the python scripts run. > Same behaviour on Linux (XFCE) and windows 7. That's because an app that communicates with standard in and standard out could be runn

Re: non-blocking getkey?

2015-11-19 Thread Ulli Horlacher
Terry Reedy wrote: > On 11/18/2015 11:50 AM, Ulli Horlacher wrote: > > Ulli Horlacher wrote: > > > >> from Tkinter import Tk > >> from tkFileDialog import askopenfilename > >> > >> Tk().withdraw() > >> file = askopenfilename() > > > > I found another glitch: >

Re: non-blocking getkey?

2015-11-18 Thread eryksun
On Wed, Nov 18, 2015 at 3:14 AM, Christian Gollwitzer wrote: > The standard terminal on Windows is very ugly, can't resize the width, and > pasting works only if you right-click -> paste. The console UI is improved in Windows 10: http://blogs.windows.com/buildingapps/2014/10/07/console-improvemen

Re: non-blocking getkey?

2015-11-18 Thread Terry Reedy
On 11/18/2015 11:50 AM, Ulli Horlacher wrote: Ulli Horlacher wrote: from Tkinter import Tk from tkFileDialog import askopenfilename Tk().withdraw() file = askopenfilename() I found another glitch: After termination of askopenfilename() the window focus i

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Ulli Horlacher wrote: > from Tkinter import Tk > from tkFileDialog import askopenfilename > > Tk().withdraw() > file = askopenfilename() I found another glitch: After termination of askopenfilename() the window focus is not returned to the calling window (xterm

Re: non-blocking getkey?

2015-11-18 Thread Jussi Piitulainen
Ulli Horlacher writes: > Steven D'Aprano wrote: > >> >> The limitation is that this will not work if any of the file names >> >> contain astral (non-BMP) chars because tk cannot handle such >> >> characters. >> > >> > What are "astral chars"? >> >> Unicode characters beyond U+. > > I see, for

Re: non-blocking getkey?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 12:51 AM, Ulli Horlacher wrote: > Steven D'Aprano wrote: > >> >> The limitation is that this will not work if any of the file names >> >> contain astral (non-BMP) chars because tk cannot handle such characters. >> > >> > What are "astral chars"? >> >> Unicode characters be

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Chris Angelico wrote: > > In my application the user MUST select files and directories (in one go). > > It's extremely uncommon to be able to select a combination of files > and directories. I have an uncommon application :-) Filetransfer of ANY size: http://fex.rus.uni-stuttgart.de:8080/ >

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Steven D'Aprano wrote: > >> The limitation is that this will not work if any of the file names > >> contain astral (non-BMP) chars because tk cannot handle such characters. > > > > What are "astral chars"? > > Unicode characters beyond U+. I see, for very exotic character sets, like Klingo

Re: non-blocking getkey?

2015-11-18 Thread Steven D'Aprano
On Thu, 19 Nov 2015 12:06 am, Ulli Horlacher wrote: > Terry Reedy wrote: > >> > from Tkinter import Tk >> > from tkFileDialog import askopenfilename >> > >> > Tk().withdraw() >> > file = askopenfilename() >> >> To get multiple names, add 's'. > > I have found it already

Re: non-blocking getkey?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 12:06 AM, Ulli Horlacher wrote: >> The limitation is that this will not work if any of the file names >> contain astral (non-BMP) chars because tk cannot handle such characters. > > What are "astral chars"? Characters not on the Basic Multilingual Plane (BMP). The Unicode

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Terry Reedy wrote: > > from Tkinter import Tk > > from tkFileDialog import askopenfilename > > > > Tk().withdraw() > > file = askopenfilename() > > To get multiple names, add 's'. I have found it already, thanks. > The limitation is that this will not work if any of t

Re: non-blocking getkey?

2015-11-18 Thread Terry Reedy
On 11/18/2015 6:01 AM, Ulli Horlacher wrote: Ulli Horlacher wrote: it is too complicated to rewrite my application from CLI to GUI. But... is there a windows program with which one can select files and the result is written to STDOUT? Found it: from Tkinter import Tk from tk

Re: non-blocking getkey?

2015-11-18 Thread Christian Gollwitzer
Am 18.11.15 um 12:01 schrieb Ulli Horlacher: Ulli Horlacher wrote: it is too complicated to rewrite my application from CLI to GUI. But... is there a windows program with which one can select files and the result is written to STDOUT? Found it: from Tkinter import Tk from tk

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Ulli Horlacher wrote: > it is too complicated to rewrite my application from CLI to GUI. > But... is there a windows program with which one can select files and the > result is written to STDOUT? Found it: from Tkinter import Tk from tkFileDialog import askopenfilename

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Christian Gollwitzer wrote: > > How can I implement such a get_paste() function? > > I need a non-blocking getkey() function. > > It must work on Windows and Linux. > > Non-blocking I/O from the commandline is OS specific. There are > different solutions, and it

Re: non-blocking getkey?

2015-11-18 Thread Christian Gollwitzer
n-blocking getkey() function. It must work on Windows and Linux. Non-blocking I/O from the commandline is OS specific. There are different solutions, and it's usually hacky (stty on Linux, Console API on Windows) Why do you not use a proper GUI toolkit to do this? It is straight-fo

non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
etween 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. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de Universitaet