473,545 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting text into the copy-paste buffer...

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,

mediocre nebula.

Sep 5 '06 #1
1 2383

David Hirschfield wrote:
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?
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.getst atusoutput("%s -o -selection primary" %

"arg" has the X selection.

Sep 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Chris Maloof | last post by:
Hello, Does anyone know how I can read the ASCII text from a console window (from another application) in WinXP? It doesn't sound like a major operation, but although I can find the window via pywin32, I haven't been able to do anything with it. I'd really just like to get the window text into a string. By "console window", I mean the...
by: Kevin | last post by:
I have a document, lets say: <Doc> <Ele1 Att1='hello'> <Ele2 Att2='goodbye'/> </Ele1> </Doc> In XSLT I need to generate an attribute value which contains part of this document as a text string, ie:
by: Patrik Carlsson | last post by:
I have a problem using Xerces with a template for a generic page-header getting a sub-tree as argument. The same stylesheet is working flawlessly in IE and Mozilla, though it would be nice to have a result-file to work with too. Here is an example (xerces only get a collapsed string through), any suggestions or current bug-reports are...
by: Aaron Gray | last post by:
<iframe name="iframe" width="100%" height="25%" src="test1.txt"> </iframe> <a href="test1.txt" target="input">one</a> <a href="test2.txt" target="input">two</a> <form name="form1"> <textarea name="textarea" cols=80 rows=18> This is a test </textarea><br>
by: Robert-Paul | last post by:
Hi there, I have this code (see below). He calls Windows API CopyFileEx to copy a file, but the source-file (string src) doesn't exists. Then I get the system error with GetLastError and FormatMessages, but by running the code I get the error "The specified procedure could not be found." instead of "File not found". Can someone tell me...
by: Neil | last post by:
I have a gridview which is being populated with no problems. I want to be able to reference the data from the cells in the row but having followed an example on MSDN cannot get any data to be displayed in a text box no matter which cell index I provide. I tried a row of code that successfully displays the rowindex of the selected row. ...
by: Larry | last post by:
I get a "Specified cast is not valid" when excuting the following line in the subroutine below: spParm = spAddImage.Parameters("@fnameIn").Value = ckfile.Text I'm not sure what I'm doing wrong to cause this error. I'm using the following to set up this parameter: spParm = spAddImage.Parameters.Add("@fnameIn", SqlDbType.VarChar, 256)
by: chippy | last post by:
I am finding that when I use the cloneNode method to copy an HTML element that contains a <script> tag, the contents of the <script> tag, (ie. the javascript) are removed. If I do this: var form1 = document.getElementById(sID).firstChild.cloneNode(true); alert(form1.outerHTML); I can see the empty <script> tags. I am wondering if there...
by: darrel | last post by:
I'm having a hell of a time figuring this out. ;o) OK, thanks to Oleg, I finally figured out how to get XHTML in my XML by using writeRaw to get it to not encode the XHTML going in. However, I can't get it back out. I'm transforming my XML using XSLT: Dim trasformedXML As New System.IO.StringWriter xslt.Transform(doc, Nothing,...
by: AshishMishra16 | last post by:
HI friends, I am using the Flex to upload files to server. I m getting all the details about the file, but I m not able to upload it to Server. Here is the code i m using for both flex & for Struts: import java.io.File; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator;
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.