Re: [Tutor] Combobox - SetValue based on selection

Magnus Lycka magnus at thinkware.se
Tue Oct 7 07:19:11 EDT 2003


Andrei <project5 at redrival.net> wrote:
> 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.

I guess you are discussing the wxPython toolkit, even if I
didn't find an explicit reference. In that case I would 
suggest that you use the wxCallAfter function. (See wx.py, 
or google, it's a Python function, and thus not in the 
wxWindows docs.)

I assume that your code in the event handling changes the
combobox too early, and the standard widget processing
overwrites you change. What you have to do then, is to
define a separate function or method that sets the value 
you want. In the event handling, you use wxCallAfter to make
sure that this function is called after the event processing
for the combobox event is finished.

-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus at thinkware.se



More information about the Tutor mailing list