hoe to get rid of bold in richtextctrl ?

hello,

I’ve a richttextctrl in which I frequently change the contents.

The only style attribute I’m using is bold (translating tags
from html).

Now I’ve a problem:

if the cursor is in a bold piece of text and I change the contents of
the richtextctrl (while focus is on a different widget),

and I try to replace the the content of the richtextctrl with the code
below

(you can see I’ve tried all kinds of statement to get
rid of the bold)

all the new text gets bold.

Anyway to prevent that ?

I’m using:

Windows XP, ‘2.8.10.1 (msw-unicode)’

thanks,

Stef Mientki

def Display_Text ( self, Text ) :

self.SetCaretPosition(0)

self.EndStyle()

self.SelectNone()

self.Clear()

#self.SetSelection(0,0)

self.SetCaretPosition(0)

self.BeginBold ()

self.WriteText ( 'aap' )

self.EndBold ()

self.EndBold ()

self.Clear()

self.WriteText (Text)

Just a guess, but I would try creating a TextAttrEx object, tell it to use a wx.NORMAL font weight, and then set that attr on the whole range of the RTC with SetStyleEx.

···

On 6/5/10 3:15 AM, Stef Mientki wrote:

hello,

I've a richttextctrl in which I frequently change the contents.
The only style attribute I'm using is bold (translating <b> tags from html).
Now I've a problem:
if the cursor is in a bold piece of text and I change the contents of
the richtextctrl (while focus is on a different widget),
and I try to replace the the content of the richtextctrl with the code below
(you can see I've tried all kinds of statement to get rid of the bold)
all the new text gets bold.
Anyway to prevent that ?

--
Robin Dunn
Software Craftsman

Sorry it took me a while to test this solution,
but your guess is right,
thanks very much !!

Apparently, the defaultstyle is set to the style, where the caret is on.
To reset the defaultstyle, it's enough to assign an "empty" TextattrEx.

    self.Clear()
    self.SetDefaultStyle ( rt.TextAttrEx () )

cheers,
Stef

···

On 07-06-2010 22:39, Robin Dunn wrote:

On 6/5/10 3:15 AM, Stef Mientki wrote:

hello,

I've a richttextctrl in which I frequently change the contents.
The only style attribute I'm using is bold (translating <b> tags from html).
Now I've a problem:
if the cursor is in a bold piece of text and I change the contents of
the richtextctrl (while focus is on a different widget),
and I try to replace the the content of the richtextctrl with the code below
(you can see I've tried all kinds of statement to get rid of the bold)
all the new text gets bold.
Anyway to prevent that ?

Just a guess, but I would try creating a TextAttrEx object, tell it to use a wx.NORMAL font
weight, and then set that attr on the whole range of the RTC with SetStyleEx.