Creating Buttons referenced like an array

Is there a way to create buttons with a command like.

btn[1]= wxButton(self, -1, MIList[i],(height*22,0),(width,22))

I keep getting erros related to the creation of the button, and I am not
sure how to create an array of buttons.

  Thanks

Mike Wagman wrote:

Is there a way to create buttons with a command like.

btn[1]= wxButton(self, -1, MIList[i],(height*22,0),(width,22))

I keep getting erros related to the creation of the button,

What are the errors? What is btn? What is MIList[i]? We can't help you unless you are unambiguous and give all the details.

and I am not
sure how to create an array of buttons.

The same way you would create a collection of any other object in Python. Create the object and append it to a list.

···

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

Perhaps my problem is in creation of the first button.

i is currently 0.

btn[i] = wxButton(self, -1, "Hello",(height*22,0),(width,22))
TypeError: object doesn't support item assignment

···

On Tue, 2003-08-05 at 12:05, Robin Dunn wrote:

Mike Wagman wrote:
> Is there a way to create buttons with a command like.
>
> btn[1]= wxButton(self, -1, MIList[i],(height*22,0),(width,22))
>
> I keep getting erros related to the creation of the button,

What are the errors? What is btn? What is MIList[i]? We can't help
you unless you are unambiguous and give all the details.

> and I am not
> sure how to create an array of buttons.

The same way you would create a collection of any other object in
Python. Create the object and append it to a list.

Perhaps my problem is in creation of the first button.

i is currently 0.

That is not a problem. Indices start with 0 in Python.

btn[i] = wxButton(self, -1, "Hello",(height*22,0),(width,22))
TypeError: object doesn't support item assignment

Could this be your problem?

l = (1,2,3)
l[0] = 1

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: object doesn't support item assignment

l = [1,2,3]
l[0] = 1

As you can see, l = (1,2,3) creates a tuple, which is like a list, but
is immutable. To create a list, use instead of ().

For future reference, it would help people trying to help you if you
could post more useful information so we don't have to guess. In this
case, at least posting how you created the btn "array" would have
immediately tipped people off to the source of the error. Often errors
aren't obvious by simply looking at the line that generated the
exception (and this seems to be one of those cases).

Regards,
Cliff

···

On Tue, 2003-08-05 at 19:50, Mike Wagman wrote:

--
When I die, don't bury me alone
         -These Immortal Souls