On Tue, Aug 6, 2013 at 2:33 AM, Ville M. Vainio <[email protected]> wrote:
> There is a rich
> text
> editor "demo" in stickynotes plugin.
I didn't know that ;-)
When I awoke this morning, I realized what the important part of the code
is, for both the Qt demo or Ville's demo. It's saving/restoring the
formatting data!
For the Qt demo, the save done in the fileSave method::
write = QTextDocumentWriter(self.fileName)
success = writer.write(self.textEdit.document())
Note that the textEdit ivar is a QTextEdit.
The restore is done in the load method::
data = file.readAll()
codec = Qt.codecForHtml(data)
s = codec.toUnicode(data)
if Qt.mightBeRichText(s):
self.textEdit.setHtml(s)
else:
s = QString.fromLocal8Bit(data)
self.textEdit.setPlainText(s)
In Ville's demo, the save is done in the focusout method, defined in
stickynoter_f::
def focusout():
...
v.b = nf.toPlainText()
...
And the restore is done in the focusin method:
def focusin():
...
if v.b != nf.toPlainText():
nf.setPlainText(v.b)
...
This code doesn't look like it will remember formatting, but that's no big
deal. We can just write the data to a uA (v.u) using the same code as Qt
demo.
In short, there now appears a straightforward route to using a typical gui
to create rich text!
Edward
P.S. At present, I see the following problems with the stickynotesr command
in the stickynotes plugin, on both Ubuntu and Windows 7. These are not
serious...
1. The rich text actions (menu items), defined in the SimpleRichText class,
are not visible in the popup editor.
2. The text is rendered as html, which means that line breaks disappear.
Also, the stickynote-new command crashes ;-)
EKR
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.