Lucas Boppre Niehues wrote:
I'm trying to make an autocomplete-ish function "*bolding*" the characters typed.
Example:
You start typing the word "text", up to "tex".
Then the following phrase appears:
"This is a *tex*t."
All possible phrases are single lined.
Unfortunately the common TextCtrl doesn't seem to support single characters "bolding". What should be the best control for this case?
Did you look at the demo? The standard TextCtrl can do bolding, highlighting, etc as long as the native widget supports it. You just need to set the style to wx.TE_RICH2
The following code from the demo is included for your reference:
<code>
t4 = wx.TextCtrl(self, -1, "If supported by the native control, this is red, and this is a different font.",
size=(200, 100), style=wx.TE_MULTILINE|wx.TE_RICH2)
t4.SetInsertionPoint(0)
t4.SetStyle(44, 47, wx.TextAttr("RED", "YELLOW"))
points = t4.GetFont().GetPointSize() # get the current size
f = wx.Font(points+3, wx.ROMAN, wx.ITALIC, wx.BOLD, True)
t4.SetStyle(63, 77, wx.TextAttr("BLUE", wx.NullColour, f))
</code>
···
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org