List Info

Thread: RichTextCtrl Dummy Question :-D




RichTextCtrl Dummy Question :-D
user name
2007-10-22 15:43:02
Hi All,

    I am thinking of replacing in my database-based
application the
StyledTextCtrl with RichTextCtrl, mostly to be able to paste
images,
tables etc... My problem is, the data for RichTextCtrl is
stored
inside the database, so I cannot use LoadFile on it. I also
don't
think I could use SetValue() or AppendText(), as these
methods do not
hold formatting informations about the saved text. Is there
a way in
which I could load the text, formatting, images and so on
from the
database and assign it to the RichTextCtrl?

Sorry for the dummy question, I have never used RichTextCtrl
:-D

Andrea.

"Imagination Is The Only Weapon In The War Against
Reality."
http://xoomer.alic
e.it/infinity77/

------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


RE: RichTextCtrl Dummy Question :-D
country flaguser name
Denmark
2007-10-22 16:56:34
>     I am thinking of replacing in my database-based 
> application the StyledTextCtrl with RichTextCtrl,
mostly to 
> be able to paste images, tables etc... My problem is,
the 
> data for RichTextCtrl is stored inside the database, so
I 
> cannot use LoadFile on it. I also don't think I could
use 
> SetValue() or AppendText(), as these methods do not
hold 
> formatting informations about the saved text. Is there
a way 
> in which I could load the text, formatting, images and
so on 
> from the database and assign it to the RichTextCtrl?
> 
> Sorry for the dummy question, I have never used
RichTextCtrl :-D
> 
Forgive me if I send you in the wrong direction - what I
have done in
the past is use the base64 module to encode the original
file to a
cStringIO stream. You will end up with a long stream of
characters
(similar to email attachements and mime encoding) that are
quite safe
for storing in the db.  
To retreive and load the file, read the string back from the
db, decode
it and store it as a temp file then load the temp file into
the
RichTextCtrl.  When done editing, reverse the process.

Of course you will want to remove the tempfile on exit too
!

I am not familiar with the controls mentioned, but hope that
helps.

Hope that helps.

G.


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


Re: RichTextCtrl Dummy Question :-D
country flaguser name
United States
2007-10-23 01:27:19
Andrea Gavana wrote:
> Hi All,
> 
>     I am thinking of replacing in my database-based
application the
> StyledTextCtrl with RichTextCtrl, mostly to be able to
paste images,
> tables etc... My problem is, the data for RichTextCtrl
is stored
> inside the database, so I cannot use LoadFile on it. I
also don't
> think I could use SetValue() or AppendText(), as these
methods do not
> hold formatting informations about the saved text. Is
there a way in
> which I could load the text, formatting, images and so
on from the
> database and assign it to the RichTextCtrl?

Take a look at OnFileViewHTML in the demo, it saves the
contents of the 
RTC to a StringIO directly from the RichTextHTMLHandler, and
then lets 
you view it as from a HtmlWindow.  I think you can probably
do something 
similar for saving to and loading from a StringIO using the

RichTextXMLHandler.  It already saves the image data in the
xml, so that 
shoudl already be taken care of, you just need to be able to
deal with 
using the StringIO stream to load and save.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java
give you jitters?  Relax with wxPython!


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )