Make the control ID explicit and analyse it in the handler:
id_=5000
for n in range(0,9):
for m in range(0,9):
casella = 'casella%dx%d' % (n,m) # more efficient
casella = wx.lib.intctrl.IntCtrl(parent=self, value=None, min=1, max=9, id=id_, size=(20,20), limited=True, allow_none=True)
id_ += 1 # give controls IDs 5000-5099
casella.Bind(wx.lib.intctrl.EVT_INT, caselles)
def caselles(evt):
id_ = evt.GetId() - 5000 # get value 0-99
n = id_ / 10
m = id_ % 10
...
Hope that helps,
Phil Mayes
···
At 11:35 AM 7/11/2006, you wrote:
Hi,
i'm a newbie, in programation in general. I'm doing my first program
and i have a simple question:
i have a lot of intctrl's in my frame. i generate them in a loop but
the problem is the binder:
for n in range(0,9):
for m in range(0,9):
casella = 'casella'+str(n)+'x'+str(m)
casella = wx.lib.intctrl.IntCtrl(parent=self, value=None, min=1,
max=9, id=wx.NewId(), size=(20,20), limited=True, allow_none=True)here comes the problem. with events and binder:
self.Bind(event=wx.lib.intctrl.EVT_INT, source=casella,
id=casella.GetId(), handler=caselles(casella))It must not the correct way... What i wanna is when casella changes
its value, pass a function (caselles) that the argument is casella
(so, not all intctrls' events will do the same, not? correct me if i'm
wrong please..).Can you help me? Thanks a lot!