event handling

Discussion in 'Python' started by Peter Nemeth, Jan 30, 2008.

  1. Peter  Nemeth

    Peter Nemeth Guest

    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
    Peter Nemeth, Jan 30, 2008
    #1
    1. Advertising

  2. On Jan 30, 11:16 am, Peter Nemeth <> 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/alan.gauld/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
    Mike Driscoll, Jan 30, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sunil

    Pager and Event Handling

    sunil, Jul 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    382
    sunil
    Jul 18, 2003
  2. Makarand

    ASP.NET Event handling.

    Makarand, Jul 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    411
    Makarand
    Jul 24, 2003
  3. Mark Tarver
    Replies:
    22
    Views:
    1,302
    J Kenneth King
    Apr 26, 2009
  4. Peter
    Replies:
    34
    Views:
    1,936
    James Kanze
    Oct 17, 2009
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    187
    Iñaki Baz Castillo
    Apr 15, 2008
Loading...

Share This Page