Custom control to enter email recipient

I need a widget to enter one or more email recipients in valid form (rfc5322)

A baseline design would be a regular TextCtrl. Validation can be done either at each key stroke and/or on ENTER key press/lose focus etc. This is straightforward to write in a few minutes and suffices for my needs.

But I am considering turning it into a small project for the holidays and writing a richer widget that comes closer to the behavior of, say, entering a recipient in gmail, offering selection/autocompletion, possibility of deleting whole emails, editing, etc.

My widget would not have to be specific to emails. More generically I am interested in the ability to select/autocomplete from a preexisting set of multiple text labels, as well as possibly edit the text of each label already added, remove a label already added or type new ones.

I note that a ComboBox permits a single selection only, a ListCtrl does not permit adding new items, and an EditableListBox does not allow selection so none of these controls by itself would suffice.

This is a design/brainstorming question, rather than an implementation details question. I would enjoying hearing thoughts or pointers to existing solutions before deciding whether I want to do this. If I end up writing a non-trivial widget I will be happy to open source it.

Hi, jmoraleda

How about stc.StyledText?
It can be used in the same way as TextCtrl but has a very fast and easy-to-use auto-completion and tool-tip functions. The demonstration of that feature can be seen in Pycrust or wxdemo/StyledTextCtrl_2.
I think it might be a candidate for your widget, but there are a few things to keep in mind:

  • Multi-line style only
  • Auto-completed words cannot include space (space is used as a separator of candidates of completion).
  • Actually, wx.stc wraps quite many features of Scintilla, so it is a kind of ‘sledgehammer to crack a nut’.:slightly_smiling_face: