I am trying to get wxPython RichTextCtrl to display superscripts. I have seend some wxWidgets code at
http://wxwidgets.10942.n7.nabble.com/rich-text-and-font-attributes-td23557.html
and also seen the documentation at
https://wxpython.org/Phoenix/docs/html/wx.TextAttr.html#wx.TextAttr.SetTextEffects
So far, I have got this and it's not working
attr = wx.richtext.RichTextAttr()
attr.SetTextEffects (wx.TEXT_ATTR_EFFECT_SUPERSCRIPT)
attr.SetTextEffectFlags (wx.TEXT_ATTR_EFFECTS)
#attr.SetTextEffectFlags (wx.TEXT_ATTR_EFFECT_SUPERSCRIPT)
attr.SetFlags (wx.TEXT_ATTR_EFFECTS)
self.myRichTextCtrl.SetStyle (currentPos, currentPos+len(value1)-1, attr)
self.myRichTextCtrl.WriteText (myString)
I know there's a fancytext widget, but it's not practical to switch to fancytext at this point.
Any help would be much appreciated!
With
SetStyleyou are applying attributes to text positions that you haven't written yet.There is an option
SetBasicStyleandSetDefaultStylewhich allow you to set the attributes for the whole document or from now on.Here is a working example.