wx.richtext xml to/from plain text conversions

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

wx.richtext xml to/from plain text conversions

Mark Summerfield-2

I am trying to write two functions, one to convert plain text to wx's rich text XML format; and the other to convert the other way. I don't need these functions to round-trip. I have a wxml_for_text(text) -> wxml function that works fine (although it seems verbose to me). But I cannot get the complementary text_for_wxml(wxml) -> text function to work.

Could anyone show me how to get text_for_wxml working? And ideally, show me how to shorten & simplify both functions if that's possible?


I've attached t.py which runs with Python 3 and wxPython 4b2. For me the output is:


<?xml version="1.0" encoding="UTF-8"?>
<richtext version="" xmlns="http://www.wxwidgets.org">
  <paragraphlayout margin-left="4,4098" margin-right="4,4098" margin-top="4,4098" margin-bottom="4,4098">
      <text>This and that.
And there's more.</text>
      <text>And more.</text>
      <text>And &lt;extra&gt; &amp;etc.


('A', b'<?xml version="1.0" encoding="UTF-8"?>\n<richtext version="" xmlns="http://www.wxwidgets.org">\n  <paragraphlayout margin-left="4,4098" margin-right="4,4098" margin-top="4,4098" margin-bottom="4,4098">\n    <paragraph>\n      <text>This and that.\nAnd there\'s more.</text>\n    </paragraph>\n    <paragraph>\n      <text>And more.</text>\n    </paragraph>\n    <paragraph>\n      <text>And &lt;extra&gt; &amp;etc.\n</text>\n    </paragraph>\n  </paragraphlayout>\n</richtext>\n')
('B', '')
('C', '')

I would have expected 'B' and 'C' to have plain text not empty strings.

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.