[PyKDE] Setting the clipboard content without creating any window
Serge Weinstock
sweinst at ukonline.co.uk
Tue Jul 4 06:27:53 BST 2006
Hi,
I'm currently writing a script which should allow me to set up the
content of the clipboard.
For this, I shouldn't need to create a window, so my first try was;
import sys
from qt import *
theApp = QApplication(sys.argv)
cb = theApp.clipboard()
print "before:", cb.text(QClipboard.Clipboard)
cb.setText("hello", QClipboard.Clipboard)
print "after:", cb.text(QClipboard.Clipboard)
The output was:
before: theApp
after: hello
But the clipboard was left unchanged...
Reading the QClipboard documentation, I found "Lastly, the X11
clipboard is event driven, i.e. the clipboard will not function properly
if the event loop is not running"
So I tried the following:
import sys
from qt import *
theApp = QApplication(sys.argv)
while theApp.hasPendingEvents():
theApp.processEvents()
##
cb = theApp.clipboard()
print "before:", cb.text(QClipboard.Clipboard)
Hi,
I'm currently writing a script which should allow me to set up the
content of the clipboard.
For this, I shouldn't need to create a window, so my first try was;
import sys
from qt import *
theApp = QApplication(sys.argv)
cb = theApp.clipboard()
print "before:", cb.text(QClipboard.Clipboard)
cb.setText("hello", QClipboard.Clipboard)
print "after:", cb.text(QClipboard.Clipboard)
The output was:
before: theApp
after: hello
But the clipboard was left unchanged...
Reading the QClipboard documentation, I found "Lastly, the X11
clipboard is event driven, i.e. the clipboard will not function properly
if the event loop is not running"
So I tried the following:
import sys
from qt import *
theApp = QApplication(sys.argv)
while theApp.hasPendingEvents():
theApp.processEvents()
##
cb = theApp.clipboard()
print "before:", cb.text(QClipboard.Clipboard)
cb.setText("hello", QClipboard.Clipboard)
print "after:", cb.text(QClipboard.Clipboard)
##
while theApp.hasPendingEvents():
theApp.processEvents()
But still the same results....
Any idea on what I do wrong?
Thanks in advance,
Serge Weinstock
cb.setText("hello", QClipboard.Clipboard)
print "after:", cb.text(QClipboard.Clipboard)
##
while theApp.hasPendingEvents():
theApp.processEvents()
But still the same results....
Any idea on what I did wrong?
Thanks in advance,
Serge Weinstock
More information about the PyQt
mailing list