after saving from richtxtctrl to db, how do I go the other way ?

the following loads contents of richtextctrl (text) into db, when I query db it looks correct.


        out = BytesIO()
handler = wx.richtext.RichTextXMLHandler()
rt_buffer = self.text.GetBuffer()
handler.SaveFile(rt_buffer, out)
self.xml_content = out.getvalue()
cx.execute("insert into notes (key, data) values (?, ?)", (key, self.xml_content))
self.conn.commit()

question how do I get it back from db and load into richtextctrl ?

I do it like this:

conn = psycopg2.connect(conn_string) # user, password and such
cur = conn.cursor()
cur.execute(query)
rows = cur.fetchall() # We have the rows returned from the db
if rows: # for every parameter used
    msg = "Please wait while we process your request..."
    busyDlg = wx.BusyInfo(msg)
    for r in rows:
      # here you would insert it in the rictextctrl

Hope this helps

···

El martes, 29 de agosto de 2017, 4:54:09 (UTC+2), dennis spera escribió:

the following loads contents of richtextctrl (text) into db, when I query db it looks correct.


        out = BytesIO()
handler = wx.richtext.        RichTextXMLHandler()
rt_buffer = self.text.GetBuffer()
handler.SaveFile(rt_buffer, out)
self.xml_content = out.getvalue()
cx.execute("insert into notes (key, data) values (?, ?)", (key, self.xml_content))
self.conn.commit()

question how do I get it back from db and load into richtextctrl ?

thanks, the issue is that when I retrieve the xml from the database and

insert it into the richtextctrl it is just inserting the text of the xml like

this:

<?xml version="1.0" encoding="UTF-8"?>

aaa

it is not rendering the attributes like setting font, etc

I want it restored like it was when the text was changed in

the richtextctrl

···

On Mon, Aug 28, 2017 at 9:00 PM, dennis spera dennis.spera@gmail.com wrote:

the following loads contents of richtextctrl (text) into db, when I query db it looks correct.


        out = BytesIO()
handler = wx.richtext.        RichTextXMLHandler()
rt_buffer = self.text.GetBuffer()
handler.SaveFile(rt_buffer, out)
self.xml_content = out.getvalue()
cx.execute("insert into notes (key, data) values (?, ?)", (key, self.xml_content))
self.conn.commit()

question how do I get it back from db and load into richtextctrl ?

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dennis Spera

Oracle 12c DBA

I am using wxpython 4.x, I think the code you posted will only

work for 3.x from what I have read or are you using 4.x as well ?

···

On Tue, Aug 29, 2017 at 12:55 PM, David Woods transana@gmail.com wrote:

  I use the RichTextXMLHandler that's included in the wx.richtext

module:

try:

We need to setup a StringIO object to emulate a file

stream = cStringIO.StringIO(text)

Create an XML Handler

handler = wx.richtext.RichTextXMLHandler()

Load the XML text via the XML Handler.

Note that for XML, the BUFFER is passed.

handler.LoadStream(self.GetBuffer(), stream)

exception handling

except:

print “XML Handler Load failed”

print

print sys.exc_info()[0], sys.exc_info()[1]

print traceback.print_exc()

  I've also written RTF and DOCx parsers for the RichTextCtrl which

work well enough for my needs.

David

  On 08/29/2017 11:50 AM, dennis spera

wrote:

      thanks, the issue is that when I retrieve

the xml from the database and

      insert it into the richtextctrl it is

just inserting the text of the xml like

this:

        <?xml version="1.0"

encoding=“UTF-8”?>

        <paragraphlayout textcolor="#000000"

fontpointsize=“9” fontfamily=“70” fontstyle=“90”
fontweight=“90” fontunderlined=“0” fontface=“Segoe UI”
alignment=“1” parspacingafter=“10” parspacingbefore=“0”
linespacing=“10” margin-left=“5,4098” margin-right=“5,4098”
margin-top=“5,4098” margin-bottom=“5,4098”>

aaa

        it is not rendering the attributes like

setting font, etc

        I want it restored like it was when the

text was changed in

the richtextctrl

  You received this message because you are subscribed to the Google

Groups “wxPython-users” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to wxpython-users+unsubscribe@googlegroups.com.

  For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

      On Mon, Aug 28, 2017 at 9:00 PM, dennis

spera dennis.spera@gmail.com
wrote:

              the following loads contents of richtextctrl (text)

into db, when I query db it looks correct.


        out = BytesIO()
handler = wx.richtext.RichTextXMLHandler        ()
rt_buffer = self.text.GetBuffer()
handler.SaveFile(rt_buffer, out)
self.xml_content = out.getvalue()
cx.execute("insert into notes (key, data) values (?, ?)", (key, self.xml_content))
self.conn.commit()

              question how do I get it back from db and load into

richtextctrl ?

            --

            You received this message because you are subscribed to

the Google Groups “wxPython-users” group.

            To unsubscribe from this group and stop receiving emails

from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

            For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).


**Dennis Spera
**

** Oracle 12c
DBA

**

          [ ](http://www.linkedin.com/pub/dennis-spera/34/810/1a8/)

Dennis Spera

Oracle 12c DBA

I’m using 2.7 so as you said my code my not work for 4.x.
Have you tried to extract the tags from the xml and using setFont and the like to use the attributes again?
You could easily use a regular expresion to search for fontpointsize=9 and use SetFontSize(9), textcolor"#000000" → SetForegroundText(000000).

I have not used an XMLControl but this is how I would do it for a wx.RichTextControl.

···

El martes, 29 de agosto de 2017, 19:05:42 (UTC+2), dennis spera escribió:

I am using wxpython 4.x, I think the code you posted will only

work for 3.x from what I have read or are you using 4.x as well ?

On Tue, Aug 29, 2017 at 12:55 PM, David Woods tran...@gmail.com wrote:

  I use the RichTextXMLHandler that's included in the wx.richtext

module:

try:

We need to setup a StringIO object to emulate a file

stream = cStringIO.StringIO(text)

Create an XML Handler

handler = wx.richtext.RichTextXMLHandler()

Load the XML text via the XML Handler.

Note that for XML, the BUFFER is passed.

handler.LoadStream(self.GetBuffer(), stream)

exception handling

except:

print “XML Handler Load failed”

print

print sys.exc_info()[0], sys.exc_info()[1]

print traceback.print_exc()

  I've also written RTF and DOCx parsers for the RichTextCtrl which

work well enough for my needs.

David

  On 08/29/2017 11:50 AM, dennis spera > > wrote:
      thanks, the issue is that when I retrieve

the xml from the database and

      insert it into the richtextctrl it is

just inserting the text of the xml like

this:

        <?xml version="1.0"

encoding=“UTF-8”?>

        <paragraphlayout textcolor="#000000"

fontpointsize=“9” fontfamily=“70” fontstyle=“90”
fontweight=“90” fontunderlined=“0” fontface=“Segoe UI”
alignment=“1” parspacingafter=“10” parspacingbefore=“0”
linespacing=“10” margin-left=“5,4098” margin-right=“5,4098”
margin-top=“5,4098” margin-bottom=“5,4098”>

aaa

        it is not rendering the attributes like

setting font, etc

        I want it restored like it was when the

text was changed in

the richtextctrl

      On Mon, Aug 28, 2017 at 9:00 PM, dennis > > > spera <dennis...@gmail.com> > > >           wrote:
              the following loads contents of richtextctrl (text)

into db, when I query db it looks correct.


        out = BytesIO()
handler = wx.richtext.        RichTextXMLHandler()
rt_buffer = self.text.GetBuffer()
handler.SaveFile(rt_buffer, out)
self.xml_content = out.getvalue()
cx.execute("insert into notes (key, data) values (?, ?)", (key, self.xml_content))
self.conn.commit()

              question how do I get it back from db and load into

richtextctrl ?

            --

            You received this message because you are subscribed to

the Google Groups “wxPython-users” group.

            To unsubscribe from this group and stop receiving emails

from it, send an email to wxpython-user...@googlegroups.com.

            For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).


**Dennis Spera
**

** Oracle 12c
DBA

**

          [ ](http://www.linkedin.com/pub/dennis-spera/34/810/1a8/)

  You received this message because you are subscribed to the Google

Groups “wxPython-users” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to wxpython-user...@googlegroups.com.

  For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).


Dennis Spera

Oracle 12c DBA

Just to let you know that wxPython 4 (Sphinx) works just fine under
python 2.7 for me at least - just pip install wxpython does the trick.

There are some areas where there were things that you could get away
with in 3 now cause asserts but in the vast majority of cases once they
are resolved for wxpython 4 they still work or work better under 3.

Of course it is well worth transitioning to wxPython 4 as it also works
with python 3 and 2020 is looming.

···

On 08/09/2017 07:38, Marcos del Amo wrote:

I'm using 2.7 so as you said my code my not work for 4.x.
Have you tried to extract the tags from the xml and using setFont and
the like to use the attributes again?

--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.

---
This email has been checked for viruses by AVG.

No, I guess I thought that was a method for automating

the applying the tags. But what you say is a good

idea and I think I will take that approach. Thanks.

···

On Fri, Sep 8, 2017 at 2:38 AM, Marcos del Amo mdelamo90@gmail.com wrote:

I’m using 2.7 so as you said my code my not work for 4.x.
Have you tried to extract the tags from the xml and using setFont and the like to use the attributes again?
You could easily use a regular expresion to search for fontpointsize=9 and use SetFontSize(9), textcolor"#000000" → SetForegroundText(000000).

I have not used an XMLControl but this is how I would do it for a wx.RichTextControl.

El martes, 29 de agosto de 2017, 19:05:42 (UTC+2), dennis spera escribió:

I am using wxpython 4.x, I think the code you posted will only

work for 3.x from what I have read or are you using 4.x as well ?

On Tue, Aug 29, 2017 at 12:55 PM, David Woods tran...@gmail.com wrote:

  I use the RichTextXMLHandler that's included in the wx.richtext

module:

try:

We need to setup a StringIO object to emulate a file

stream = cStringIO.StringIO(text)

Create an XML Handler

handler = wx.richtext.RichTextXMLHandler()

Load the XML text via the XML Handler.

Note that for XML, the BUFFER is passed.

handler.LoadStream(self.GetBuffer(), stream)

exception handling

except:

print “XML Handler Load failed”

print

print sys.exc_info()[0], sys.exc_info()[1]

print traceback.print_exc()

  I've also written RTF and DOCx parsers for the RichTextCtrl which

work well enough for my needs.

David

  On 08/29/2017 11:50 AM, dennis spera

wrote:

      thanks, the issue is that when I retrieve

the xml from the database and

      insert it into the richtextctrl it is

just inserting the text of the xml like

this:

        <?xml version="1.0"

encoding=“UTF-8”?>

        <paragraphlayout textcolor="#000000"

fontpointsize=“9” fontfamily=“70” fontstyle=“90”
fontweight=“90” fontunderlined=“0” fontface=“Segoe UI”
alignment=“1” parspacingafter=“10” parspacingbefore=“0”
linespacing=“10” margin-left=“5,4098” margin-right=“5,4098”
margin-top=“5,4098” margin-bottom=“5,4098”>

aaa

        it is not rendering the attributes like

setting font, etc

        I want it restored like it was when the

text was changed in

the richtextctrl

      On Mon, Aug 28, 2017 at 9:00 PM, dennis

spera dennis...@gmail.com
wrote:

              the following loads contents of richtextctrl (text)

into db, when I query db it looks correct.


        out = BytesIO()
handler = wx.richtext.RichTextXMLHandler        ()
rt_buffer = self.text.GetBuffer()
handler.SaveFile(rt_buffer, out)
self.xml_content = out.getvalue()
cx.execute("insert into notes (key, data) values (?, ?)", (key, self.xml_content))
self.conn.commit()

              question how do I get it back from db and load into

richtextctrl ?

            --

            You received this message because you are subscribed to

the Google Groups “wxPython-users” group.

            To unsubscribe from this group and stop receiving emails

from it, send an email to wxpython-user...@googlegroups.com.

            For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).


**Dennis Spera
**

** Oracle 12c
DBA

**

          [ ](http://www.linkedin.com/pub/dennis-spera/34/810/1a8/)
  --

  You received this message because you are subscribed to the Google

Groups “wxPython-users” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to wxpython-user...@googlegroups.com.

  For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).


Dennis Spera

Oracle 12c DBA

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dennis Spera

Oracle 12c DBA