Combobox - SetValue based on selection

Hello,

I have a combobox with a number of predefined items. When an item is chosen, I don't want that item itself to be set as value in the text field of the combobox, but a text *associated* with that item (using a dictionary). E.g. if item "1" is chosen, the text field should say "one". I tried EVT_COMBOBOX, but after my function is processed, the associated text is replaced by the selected item again in the text field of the combobox.

How can I solve this?

Andrei

···

=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5@bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP.

Andrei wrote:

Hello,

I have a combobox with a number of predefined items. When an item is chosen, I don't want that item itself to be set as value in the text field of the combobox, but a text *associated* with that item (using a dictionary). E.g. if item "1" is chosen, the text field should say "one". I tried EVT_COMBOBOX, but after my function is processed, the associated text is replaced by the selected item again in the text field of the combobox.

How can I solve this?

It will probably work if you set the selection after your event handler has completed. Using wxCallAfter will help.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Andrei wrote:

Hello,

I have a combobox with a number of predefined items. When an item is chosen, I don't want that item itself to be set as value in the text field of the combobox, but a text *associated* with that item (using a dictionary). E.g. if item "1" is chosen, the text field should say "one". I tried EVT_COMBOBOX, but after my function is processed, the associated text is replaced by the selected item again in the text field of the combobox.

How can I solve this?

It will probably work if you set the selection after your event handler has completed. Using wxCallAfter will help.

Thanks, it works.

···

--
Yours,

Andrei

=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5@bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP.