Phoenix
Phoenix copied to clipboard
Waved underline not displayed in RichTextCtrl on linux
Operating system: Linux Mint 20.2 wxPython version & source: wxPython 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5 (built from https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04 using pip). Python version & source: Python 3.8.10 from Linux Mint distribution.
Description of the problem: In the wxPython 4.1.1 documentation for wx.TextAttr.SetFontUnderlineType() it says:
Note On wxGTK, underline colour is only supported by GTK3. wx.TEXT_ATTR_UNDERLINE_SPECIAL is shown as a waved line. GTK might overrule the colour of wx.TEXT_ATTR_UNDERLINE_SPECIAL.
However, when I run the test app below it only shows a straight grey/black underline, 2 pixels high.
Code Example (click to expand)
import wx
import wx.richtext as rt
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((300, 200))
self.SetTitle("RichTextCtrl")
self.main_panel = wx.Panel(self, wx.ID_ANY)
main_sizer = wx.BoxSizer(wx.VERTICAL)
self.rtc = rt.RichTextCtrl(self.main_panel, wx.ID_ANY, style=rt.RE_MULTILINE)
main_sizer.Add(self.rtc, 1, wx.EXPAND, 0)
self.main_panel.SetSizer(main_sizer)
self.Layout()
self.rtc.BeginFontSize(14)
self.rtc.WriteText("What can you do with this thing? ")
self.rtc.EndFontSize()
# Apply waved underline?
attr = rt.RichTextAttr()
attr.SetFontUnderlineType(wx.TEXT_ATTR_UNDERLINE_SPECIAL, colour=wx.RED)
self.rtc.SetStyle(13, 20, attr)
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None, wx.ID_ANY, "")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()
I have attached a zoomed screen dump showing the effect.

Note: If I change the RichTextCtrl to a wx.TextCtrl, then a waved underline is displayed.
This issue has been mentioned on Discuss wxPython. There might be relevant details there:
https://discuss.wxpython.org/t/waved-underline-in-richtextctrl/35717/3
As best as I can tell, RichTextCtrl doesn't implement the new text underline styles.
My suggestion would be to file a Trac ticket: https://trac.wxwidgets.org/
Ticket has been raised: https://trac.wxwidgets.org/ticket/19363
One response so far:
No, I think this style is supported only in wxTextCtrl
Thanks - hopefully someone will be interested in implementing that feature for wxRichTextCtrl.
Any update on this?
The original Trac ticket has been migrated to an issue in the wxWidgets GitHub repository: https://github.com/wxWidgets/wxWidgets/issues/19363.
There have been no updates.
Any update on this?
Someone needs to implement the feature in wxWidgets first, no need to ask here.