TextCtrl for bolding single characters?

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 text.”

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?

Just to mention, those are the options I found:

wx.richtext.RichTextCtrl
wx.stc.StyledTextCtrl
wx.html.HtmlWindow

RichTextCtrl seems to me to be the simpler, is that true?

RichTextCtrl fitted the task perfectly, but unfortunately it seems to be multiline only.

There is a little SpinCtrl that comes together with the RichTextCtrl that I simply can’t remove…

screenshot-2009-03-01-155233.jpg

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