Thanks a lot for helping me to understand this a little more. I think
it's fantastic that there are so many people out there willing to share
their knowledge and impart a little wisdom to those who need it. Thanks
for taking the time to teach.
It seems so simple now :^)
simon.arrowsmith@aprsmartlogik.com 11/03/04 02:11:11 AM >>>
I am trying to create wx objects dynamically, for example:
List = [(button),(textctrl),(button),(checkbox)]
bindex,tindex,cindex = 1
for item in List:
if item == 'button':
b%s = wx.Button(self,-1,'') % bindex
bindex += 1elif item == 'textctrl':
t%s = wx.TextCtrl(self,-1,'') % tindex
tindex += 1else:
c%s = wx.CheckBox(self,-1) % cindex
cindex += 1
I get "SyntaxError: can't assign to operator". Maybe you
know what I'm
trying to do is possible, thanks for any hints.
I'm guessing "what you're trying to do" is end up with a set
of objects bound to b1, t1, b2 and c1. You *can* do this using
exec, but I've got to wonder why you'd want to, given that you'd
have to jump through the same exec hoops to use them. Much
better to stick them in dicts:
b = {}
...
if item == 'button':
b[bindex] = wx.Button(self,-1,'')
bindex += 1
or arrays:
b =
...
if item == 'button':
b.append(wx.Button(self,-1,''))
···
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org