kyosohma at gmail.com
Wed Jan 30 19:33:41 CET 2008
On Jan 30, 11:16 am, Peter Nemeth <pnem... at fit.edu> wrote:
> Hi ,
> I am working on a stellar spectral analysis pipeline in Python. My OS is
> Suse 10.0, and i use Python 2.5 . I have found difficulties with keyboard
> event handling. My code communicates with the user through an xterm window
> and shows graphs in a Gnuplot window. At a certain point i start an
> infinite loop in order to select multiple spectral regions by mouse-clicks
> over the Gnuplot graph. I would like to terminate this loop by a single
> keystroke, but i can not get it done. I use 'thread' to run this process
> in the background waiting for a keystroke. I don't want to use tkinter,
> widgets or pygame because those require a popup surface to work in and i
> already have the gnuplot window.
> I tried a C like getch() function, but that pauses the code waiting for
> key press instead of scanning the event queue.
> Is there any other means for general event handling in Python?
> Any help would be greatly appreciated.
I would use wxPython, but since you seem against that, here's what I
found using Google-fu:
It sounds very similar to what you are doing and it shows how to do it
in both Windows and Linux.
Threads are annoying buggers. You'll probably want to have one thread
catching key-presses and storing them in a file or "file-like" object
and have your other thread read from it periodically. I'm not sure
that the link above mentions that.
Hope that helps!
More information about the Python-list