[wxPython-users] dynamic number of buttons

Robin Dunn robin at alldunn.com
Tue Aug 1 08:42:14 PDT 2006


Timothy Smith wrote:
> Josiah Carlson wrote:
>> Timothy Smith <timothy at open-networks.net> wrote:
>>  
>>> i want to create a dynamic number of buttons, what is the preffered 
>>> method of doing this? create a custom button class or something and 
>>> loop through my list of names creating a new instance each time?
>>>     
>>
>> Create a set of buttons.
>> If you need more, create more (remember to add to a sizer).
>> If you need different names, .SetLabel()
>> If you need fewer, .Hide() the buttons.
>> Dispatch action based on event.GetEventItem().GetLabel() .
>> Always remember to .Layout() the parent after any change.
>>
>>
>>  - Josiah
>>   
> yeah i was kind of hoping i could create them dynamiclly from my db :(

There's nothing to prevent you from doing that.  I think that Josiah's 
message was just to remind you that sometimes you need to do more than 
just create the button.

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





More information about the wxpython-users mailing list