wxPython 4.1.1 RichTextCtrl changing paragraph style ignores font size and weight

Ondrej Mejzlik <[email protected]> Fri, 11 Dec 2020 03:44:42 -0800 (PST)
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
Hi,

I need some help manipulating styles in RichTextCtrl. I am using python3 on 
Fedora 32, and wxPython 4.1.1.

The code here can be run to reproduce the issue I am having:
https://stackoverflow.com/questions/65200444/wxpython-switching-styles-in-richtextctrl-does-not-work

When you run the script it inserts 3 paragraphs into the text field. Click 
on one of the red lines and then apply the blue style from the style picker 
at the bottom. Notice that it sort of adds the style to the already 
existing style and places it over, but does not change the font size and 
boldness. But in the code, each style redefines all the properties of the 
style including size and weight.

Also notice that if you start a new paragraph in the app yourself by 
pressing the enter key on the last blank line and then select a style, 
switching the styles then works correctly.

Why is this happening? What did I do wrong?

I have experimented further with this code and managed to get the 3 
paragraphs initially display correctly without the white blank strips 
around them by using:
self.rtc.SetDefaultStyle(self
._stylesheet.FindParagraphStyle(Strings.style_paragraph).GetStyle())
I also noticed that position of the self.rtc.Newline() matters. The 
behavior changes in a weird way when you place it before self.rtc.EndParagraphStyle() 
or after it.

I tried setting base style and default style in different ways and to 
different values, but none of it helped with the styles not being applied 
correctly.

I have already asked this question here:
https://discuss.wxpython.org/t/richtextctrl-changing-style-does-not-replace-previous-style/35066
Here:
https://stackoverflow.com/questions/65200444/wxpython-switching-styles-in-richtextctrl-does-not-work
And on the general [email protected] mail list
Nobody so far has been able to answer it. I am running out of options 
unfortunately and it seems like this just does not work.

If it is something simple and stupid that I overlooked, please tell me. 
This is blocking further development of my program and I can not find the 
solution myself.

Thank you.

O.

-- 
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 [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/ab8d767e-4a3b-4464-95ce-44e0b5339c0fn%40googlegroups.com.