Invoking GUI for app running in background with a keypress

Discussion in 'Python' started by Mathias Dahl, Aug 15, 2005.

  1. Mathias Dahl

    Mathias Dahl Guest

    I am creating a small app called PyQe
    (http://klibb.com/cgi-bin/wiki.pl/PyQe) to launch commands and
    programs quickly. I works more or less as I want it now and I have
    managed to make my window manager (Metacity) under Mandrake GNU/Linux
    start my program so that it can be started easily with just a
    keypress.

    Now, the only annoyance I have is that when I have not started the
    program for a while, the OS seems to not have Python or the program in
    "the cache" (or whatever, what I mean is that if I have started the
    program "recently" it starts fast the next time) anymore, which means
    that the program, even though quite small, takes about a second to
    start. This is too slow to feel good given the nature of the program
    (a quick launcher).

    I have tried making it start faster by calling python with the -S
    switch and by compiling my program to a .pyc file. It has not helped
    much.

    So, I was wondering if I could have my program running in the
    background and instead capture a certain keystroke (the same one I
    have my window manager to capture now) to make the GUI appear.

    How does one go about doing this? I found a small program written in C
    (xbindkeys) that can do this and understand that it probably involves
    a lot of "low-level" stuff in X which feels a bit "scary" :). Any
    clues of doing this "easily" in Python + some module?

    /Mathias
     
    Mathias Dahl, Aug 15, 2005
    #1
    1. Advertising

  2. Mathias Dahl

    Mike Meyer Guest

    Mathias Dahl <> writes:

    > How does one go about doing this? I found a small program written in C
    > (xbindkeys) that can do this and understand that it probably involves
    > a lot of "low-level" stuff in X which feels a bit "scary" :). Any
    > clues of doing this "easily" in Python + some module?


    Check out the python xlib implementation <URL:
    http://sourceforge.net/projects/python-xlib >. It's a python library
    that speaks native X - no C required. That lets you do those low-level
    things in Python in a straightforward manner. It's not getting a lot
    of work lately - because it's largely a finished product. I use it
    heavily on a daily basis.

    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, Aug 16, 2005
    #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. Toby
    Replies:
    1
    Views:
    386
    Kevin Spencer
    Dec 23, 2003
  2. Replies:
    2
    Views:
    679
    Michael Hoffman
    Jun 24, 2005
  3. Mathias Dahl
    Replies:
    1
    Views:
    427
  4. Mathias Dahl
    Replies:
    0
    Views:
    337
    Mathias Dahl
    Oct 22, 2005
  5. Mathias Dahl

    Listening for keypress in the background

    Mathias Dahl, Oct 22, 2005, in forum: Python
    Replies:
    4
    Views:
    525
    Peter Hansen
    Oct 23, 2005
Loading...

Share This Page