wxPython 4 set max length for MultiLine

Hi all,
Is somebody has already developed a function for replacing “SetMaxLength” for MultiLine wx.TextCtrl ?

I assume you are referring to this text in the docs, “Note that in wxGTK this function may only be used with single line text controls.”

The issue is that there are two different GTK widgets that are used, depending on if it is a single-line or a multi-line wx.TextCtrl. It’s either a GtkEntry or a GtkEditable. There is a gtk api for setting the max length on the former, (gtk_entry_set_max_length,) but there isn’t anything like that for the later.

It probably wouldn’t be too hard to implement an effective max length by checking it yourself in an EVT_TEXT handler, but that would get slower as the text gets longer so it would probably only be worth the overhead when the text is relatively small.