create choices list for wx.Choice on the fly

If I understand what you want, I believe so. But I think if you put the
creation of the list under the EVT_CHOICE/COMBOBOX events I’m not
sure it will work, because the previous list is shown during the event?
You could do it by putting it under a mouse event like
EVT_ENTER_WINDOW, and then under that event first call a function
that makes your list (self.newlist) on the fly based on whatever conditions
are going on, and then use something like

self.choice1.SetItems(self.newlist).

You’d also have to do something to prevent the mouse event
from erasing the currently shown item each time the user re-enters
the choice window, but you could do that with checking whether they

have already just done it, or whatever you want.

There’s probably a more elegant way that will be posted shortly by
someone else…

···

On Nov 26, 2007 3:50 PM, Martin Landa landa.martin@gmail.com wrote:

Hi all,

I wonder if it is possible to create choices list for wx.Choice or
wx.ComboBox on the fly. For example on EVT_CHOICE/COMBOBOX event.

Thanks for any hits! Martin

Hi,

thanks for the answer! I just overlooked SetItems() method. Now resolved.

Martin

···

2007/11/27, C M <cmpython@gmail.com>:

On Nov 26, 2007 3:50 PM, Martin Landa <landa.martin@gmail.com> wrote:
> Hi all,
>
> I wonder if it is possible to create choices list for wx.Choice or
> wx.ComboBox on the fly. For example on EVT_CHOICE/COMBOBOX event.
>
> Thanks for any hits! Martin
>

If I understand what you want, I believe so. But I think if you put the
creation of the list under the EVT_CHOICE/COMBOBOX events I'm not
sure it will work, because the previous list is shown during the event?
You could do it by putting it under a mouse event like
EVT_ENTER_WINDOW, and then under that event first call a function
that makes your list (self.newlist) on the fly based on whatever conditions
are going on, and then use something like

self.choice1.SetItems(self.newlist).

You'd also have to do something to prevent the mouse event
from erasing the currently shown item each time the user re-enters
the choice window, but you could do that with checking whether they
have already just done it, or whatever you want.

There's probably a more elegant way that will be posted shortly by
someone else...

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *