Getting text into the copy-paste buffer...

Discussion in 'Python' started by David Hirschfield, Sep 5, 2006.

  1. Strange request, but is there any way to get text into the linux
    copy-paste buffer from a python script ?

    I know the standard python libraries won't have that functionality
    (except as a side-effect, perhaps?), but is there a simple trick that
    would do it on linux? A command line to get text into the buffer? Using
    a gui toolkit as a proxy to get text in there?

    I actually have a need for this, though it sounds bizarre,
    thanks in advance,
    David Hirschfield, Sep 5, 2006
    1. Advertisements

  2. David Hirschfield

    kdart Guest

    There's a utility called xclip that you can wrap with popen2 or
    something similar. I use my own proctools:

    import proctools
    XCLIP = proctools.which("xclip")
    es, arg = proctools.getstatusoutput("%s -o -selection primary" %

    "arg" has the X selection.
    kdart, Sep 5, 2006
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.