Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

Waved underline not displayed in RichTextCtrl on linux

Open ghost opened this issue 3 years ago • 9 comments
trafficstars

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.

zoomed_non_waved_underline

Note: If I change the RichTextCtrl to a wx.TextCtrl, then a waved underline is displayed.

ghost avatar Jan 02 '22 08:01 ghost

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

RobinD42 avatar Jan 02 '22 10:01 RobinD42

As best as I can tell, RichTextCtrl doesn't implement the new text underline styles.

swt2c avatar Jan 02 '22 16:01 swt2c

My suggestion would be to file a Trac ticket: https://trac.wxwidgets.org/

swt2c avatar Jan 06 '22 14:01 swt2c

Ticket has been raised: https://trac.wxwidgets.org/ticket/19363

One response so far:

No, I think this style is supported only in wxTextCtrl

reticulatus avatar Jan 09 '22 14:01 reticulatus

Thanks - hopefully someone will be interested in implementing that feature for wxRichTextCtrl.

swt2c avatar Jan 09 '22 14:01 swt2c

Any update on this?

Athwale avatar Oct 29 '23 09:10 Athwale

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.

reticulatus avatar Oct 29 '23 10:10 reticulatus

Any update on this?

Athwale avatar Jun 10 '24 18:06 Athwale

Someone needs to implement the feature in wxWidgets first, no need to ask here.

swt2c avatar Jun 10 '24 18:06 swt2c