Re: Can choice control have dynamically generated options ?

Riaan Booysen <[email protected]> Thu, 2 Apr 2009 00:50:00 +0200
Newsgroups gmane.comp.ide.boa-constructor.user
Message-ID <[email protected]>
Hi Tanay,

2009/4/1 Tanay Shah <[email protected]>:
> Hello there,
> I want to know if it is possible to have the options in a wx.Choice control
> in a dynamic manner instead of the static options ?
> If it is possible then, how can I do it ?
> Thanks in advance

If you mean dynamic as in values that change while your program is
running, then please follow
Werners instructions.

If you mean dynamic as in other values than the statically defined
values in the Designer then yes
you can do this with a feature in Boa called special attributes.

See an example in Examples/advanced/SpecialAttributes/wxFrame1.py

There is also help about it on the "Working with generated source"
page in the application help.

In short, before the call to self._init_ctrls(...) you can define a
design-time value for the parameter
in the generated source followed by the run-time value which is
usually set from a parameter
passed to the constructor.

e.g.

   def __init__(self, parent, myChoices):
        self.myChoices = ['design-time', 'choices']
        self.myChoices = myChoices
        self._init_ctrls(parent)

Now you can change the "choices" parameter of your wx.Choice to be
choices=self.myChoice

Cheers,
Riaan.

------------------------------------------------------------------------------