RichTextAttr vs. TextAttrEx

Hi,

I am trying to retrieve the character style of a piece of RichText. I have a RichTextCtrl object ‘rtc’ and use the following code:

import wx.richtext as rc

    oldStyle = rc.RichTextAttr()
    self.rtc.GetStyle(position = 0, style = oldStyle)
    print oldStyle.GetFontFaceName()

I get the following eroor:

AttributeError: ‘TextAttrEx’ object has no attribute ‘GetFontFaceName’

For some reason oldStyle is an TextAttrEx object instead of RichTextAttr. Does anyone have a clue what I am doing wrong here?

Thanks for your help.

Frans

···

Ook nieuwsgierig naar de nieuwe Messenger? Download 'm hier

Frans Stronkman wrote:

Hi,
I am trying to retrieve the character style of a piece of RichText. I have a RichTextCtrl object 'rtc' and use the following code:
import wx.richtext as rc

        oldStyle = rc.RichTextAttr()
        self.rtc.GetStyle(position = 0, style = oldStyle)
        print oldStyle.GetFontFaceName()

I get the following eroor:
AttributeError: 'TextAttrEx' object has no attribute 'GetFontFaceName'
For some reason oldStyle is an TextAttrEx object instead of RichTextAttr. Does anyone have a clue what I am doing wrong here?

RichTextAttr is just a compatibility alias for TextAttrEx. Everything in the python wrappers for RichTextCtrl switched to using just TextAttrEx a couple releases ago. (The C++ code has overloads for both of them for most functions, I just chose to support one for the wrappers to save a bunch of hassle.)

Try style.GetFont().GetFaceName() instead.

···

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

Hi Robin,

Thanks. Got it.

Frans

···

Date: Wed, 17 Dec 2008 20:08:27 -0800
From: robin@alldunn.com
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] RichTextAttr vs. TextAttrEx

Frans Stronkman wrote:

Hi,

I am trying to retrieve the character style of a piece of RichText. I
have a RichTextCtrl object ‘rtc’ and use the following code:

import wx.richtext as rc

oldStyle = rc.RichTextAttr()
self.rtc.GetStyle(position = 0, style = oldStyle)
print oldStyle.GetFontFaceName()

I get the following eroor:

AttributeError: ‘TextAttrEx’ object has no attribute ‘GetFontFaceName’

For some reason oldStyle is an TextAttrEx object instead
of RichTextAttr. Does anyone have a clue what I am doing wrong here?

RichTextAttr is just a compatibility alias for TextAttrEx. Everything
in the python wrappers for RichTextCtrl switched to using just
TextAttrEx a couple releases ago. (The C++ code has overloads for both
of them for most functions, I just chose to support one for the wrappers
to save a bunch of hassle.)

Try style.GetFont().GetFaceName() instead.


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


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


Ook nieuwsgierig naar de nieuwe Messenger? Download 'm hier