Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > event handling

Reply
Thread Tools

event handling

 
 
Peter Nemeth
Guest
Posts: n/a
 
      01-30-2008

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.


Sincerely,
Peter

 
Reply With Quote
 
 
 
 
Mike Driscoll
Guest
Posts: n/a
 
      01-30-2008
On Jan 30, 11:16 am, Peter Nemeth <(E-Mail Removed)> 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.
>
> Sincerely,
> Peter


I would use wxPython, but since you seem against that, here's what I
found using Google-fu:

http://www.freenetpages.co.uk/hp/ala...d/tutevent.htm

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!

Mike
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
signal handling and (structured) exception handling Peter C++ 34 10-17-2009 10:03 AM
python list handling and Lisp list handling Mark Tarver Python 22 04-26-2009 09:36 PM
Is faster handling hexadecimal values than handling chars? IƱaki Baz Castillo Ruby 1 04-15-2008 09:04 AM
ASP.NET Event handling. Makarand ASP .Net 0 07-24-2003 01:46 PM
Pager and Event Handling sunil ASP .Net 2 07-18-2003 09:08 PM



Advertisments