sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #53331
[Bug 1317773] Re: [request] want to put RTF-formated text to the clipboard - solution
** Changed in: sikuli
Milestone: 2.0.0 => 2.1.0
--
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1317773
Title:
[request] want to put RTF-formated text to the clipboard - solution
Status in Sikuli:
In Progress
Bug description:
Hi all!
I need put the RTF formated string and "text/rtf" DataFlavor into
clipboard . Here is code what I started:
from java.awt import Toolkit
from java.awt.datatransfer import Clipboard, StringSelection, DataFlavor, UnsupportedFlavorException
from java.io import *
def ClipboardPutRtfString(rtf_str):
cb_data = StringSelection(rtf_str)
cb = Toolkit.getDefaultToolkit().getSystemClipboard()
RTF_FLAVOR = DataFlavor("text/rtf", "Rich Text Format")
p = (cb_data, RTF_FLAVOR)
cb.setContents(p, None)
if __name__ == '__main__' :
RTF_STRING = u"{\\rtf1\\ansi\\deff0\r\n{\\colortbl;\\red0\\green0\\blue0;\\red255\\green0\\blue0;}\r\nThis line is the default color\\line\r\n\\cf2\r\nThis line is красная\\line\r\n\\cf1\r\nThis line is the default color\r\n}\r\n}"
ClipboardPutRtfString(RTF_STRING)
But now I'm sticked with how prepare transferable p object in Jython
to pass it to setContents method, because my example gets error:
[error] TypeError ( setContents(): 1st arg can't be coerced to java.awt.datatransfer.Transferable )
[error] --- Traceback --- error source first line: module ( function ) statement ##: main ( ClipboardPutRtfString ) cb.setContents(p, None)
[error] --- Traceback --- end --------------
To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1317773/+subscriptions
References