I have been trying to get a waved underline in a RichTextCtrl which is typically used by spell checkers.
In the 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.
I have not found any examples of using that method with a RichTextCtrl and have not yet had any success using it. The following code only produced a straight grey/black underline.
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()
Any advice on the correct way to get a waved underline will be much appreciated!
[I am using Python 3.8.10 + wxPython 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5 + Linux Mint 20.2].