[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Copying to QClipboard
From:       "Jake Richards" <blaven () gmail ! com>
Date:       2008-06-19 19:56:55
Message-ID: 8467e2d90806191256u5fa0491dyacd2f742a8cec4fd () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello:
  I am having a little trouble with the QClipboard in linux.  I seem to be
able to read from the clipboard, but am unable to write to it.  Using the
code below, I get what is currently hilighted and print it out, then try to
set the clipboard, but when I try to paste (using middle mouse button)
nothing is pasted.  We have QT4.3.2 and using an older build of 64 bit
fedora.    Anyone have any tips on how I can do a setText and middle mouse
click in another program the text I set?  Thanks

#!/usr/bin/python
import sys
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)
myClipBoard = QApplication.clipboard()
test = myClipBoard.text("plain",QClipboard.Selection)
print "The clipboard has " + test
myClipBoard.setText("This is a test of my clipboard",QClipboard.Selection)
myClipBoard.setText("This is a test of my clipboard",QClipboard.Clipboard)
test = myClipBoard.text("plain",QClipboard.Selection)
print "The clipboard has " + test

[Attachment #5 (text/html)]

Hello:<br>&nbsp; I am having a little trouble with the QClipboard in linux.&nbsp; I \
seem to be able to read from the clipboard, but am unable to write to it.&nbsp; Using \
the code below, I get what is currently hilighted and print it out, then try to set \
the clipboard, but when I try to paste (using middle mouse button)&nbsp; nothing is \
pasted.&nbsp; We have QT4.3.2 and using an older build of 64 bit \
fedora.&nbsp;&nbsp;&nbsp; Anyone have any tips on how I can do a setText and middle \
mouse click in another program the text I set?&nbsp; Thanks<br> \
<br>#!/usr/bin/python<br>import sys<br>import time<br>from PyQt4.QtCore import \
*<br>from PyQt4.QtGui import *<br><br>app = QApplication(sys.argv) <br>myClipBoard = \
QApplication.clipboard()<br>test = \
myClipBoard.text(&quot;plain&quot;,QClipboard.Selection)<br> print &quot;The \
clipboard has &quot; + test<br>myClipBoard.setText(&quot;This is a test of my \
clipboard&quot;,QClipboard.Selection)<br>myClipBoard.setText(&quot;This is a test of \
my clipboard&quot;,QClipboard.Clipboard)<br> test = \
myClipBoard.text(&quot;plain&quot;,QClipboard.Selection)<br>print &quot;The clipboard \
has &quot; + test<br><br>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic