wxPython access to RichTextCtrl

Hello,
I am trying to control export of RichTextCtrl content, by defining named styles and then looping over the nodes in the buffer, export each into HTML that wouldn't be cluttered by too much mark up like font etc. and also to be able to produce HTML that would have <h1> instead of specified font. But I don't seem to be able to get lower that a paragraph.

buffer = myrichtextctrl.GetBuffer ()
nodes = buffer.GetChildren ()
for para in nodes:
    print para

The paragraphs are wx.richtext.RichTextObject. I have also split the paragraph by defining character styles. How do I get to the lower level so I extract character style information?

I am doing this as a test so I understand how it works before I try to write proper RichTextFileHandler.

Thanks
Petr

Petr Šimon wrote:

Hello,
I am trying to control export of RichTextCtrl content, by defining named styles and then looping over the nodes in the buffer, export each into HTML that wouldn't be cluttered by too much mark up like font etc. and also to be able to produce HTML that would have <h1> instead of specified font. But I don't seem to be able to get lower that a paragraph.

buffer = myrichtextctrl.GetBuffer ()
nodes = buffer.GetChildren ()
for para in nodes:
   print para

The paragraphs are wx.richtext.RichTextObject. I have also split the paragraph by defining character styles. How do I get to the lower level so I extract character style information?

I am doing this as a test so I understand how it works before I try to write proper RichTextFileHandler.

Since SWIG by default creates new proxy objects for returned pointers, and doesn't do anything to figure out what is the real type being pointed to (it may be of some derived class) then we have to do some work ourselves to make it do what is expected. Please try the attached patch.

rtotype.patch (1.5 KB)

···

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

Robin Dunn wrote:

Petr Šimon wrote:

Hello,
I am trying to control export of RichTextCtrl content, by defining named styles and then looping over the nodes in the buffer, export each into HTML that wouldn't be cluttered by too much mark up like font etc. and also to be able to produce HTML that would have <h1> instead of specified font. But I don't seem to be able to get lower that a paragraph.

buffer = myrichtextctrl.GetBuffer ()
nodes = buffer.GetChildren ()
for para in nodes:
   print para

The paragraphs are wx.richtext.RichTextObject. I have also split the paragraph by defining character styles. How do I get to the lower level so I extract character style information?

I am doing this as a test so I understand how it works before I try to write proper RichTextFileHandler.

Since SWIG by default creates new proxy objects for returned pointers, and doesn't do anything to figure out what is the real type being pointed to (it may be of some derived class) then we have to do some work ourselves to make it do what is expected. Please try the attached patch.

------------------------------------------------------------------------

_______________________________________________
wxpython-dev mailing list
wxpython-dev@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev

Many thanks, patch works fine.

Petr Šimon wrote:

Robin Dunn wrote:

Petr Šimon wrote:

Hello,
I am trying to control export of RichTextCtrl content, by defining named styles and then looping over the nodes in the buffer, export each into HTML that wouldn't be cluttered by too much mark up like font etc. and also to be able to produce HTML that would have <h1> instead of specified font. But I don't seem to be able to get lower that a paragraph.

buffer = myrichtextctrl.GetBuffer ()
nodes = buffer.GetChildren ()
for para in nodes:
   print para

The paragraphs are wx.richtext.RichTextObject. I have also split the paragraph by defining character styles. How do I get to the lower level so I extract character style information?

I am doing this as a test so I understand how it works before I try to write proper RichTextFileHandler.

Since SWIG by default creates new proxy objects for returned pointers, and doesn't do anything to figure out what is the real type being pointed to (it may be of some derived class) then we have to do some work ourselves to make it do what is expected. Please try the attached patch.

------------------------------------------------------------------------

_______________________________________________
wxpython-dev mailing list
wxpython-dev@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev

Many thanks, patch works fine.
_______________________________________________
wxpython-dev mailing list
wxpython-dev@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev

Just wanted to ask, will that patch make into the some recent release?
Thanks

Petr Šimon wrote:

Since SWIG by default creates new proxy objects for returned pointers, and doesn't do anything to figure out what is the real type being pointed to (it may be of some derived class) then we have to do some work ourselves to make it do what is expected. Please try the attached patch.

Just wanted to ask, will that patch make into the some recent release?

I don't have access to the time machine at the moment, so it won't be in a recent release, but it iwll be in a future one. :wink:

···

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

Robin Dunn wrote:

Petr Šimon wrote:

Since SWIG by default creates new proxy objects for returned pointers, and doesn't do anything to figure out what is the real type being pointed to (it may be of some derived class) then we have to do some work ourselves to make it do what is expected. Please try the attached patch.

Just wanted to ask, will that patch make into the some recent release?

I don't have access to the time machine at the moment, so it won't be in a recent release, but it iwll be in a future one. :wink:

Well, can't say that was a typo, can't I? :slight_smile: Thanks