I am setting up a NumericUpDown with python eto in a class.
the following is a part of my code
class MyEtoClass(forms.Form): def __init__(self): self.Title = 'My Title' def addnumeric(name='myslider'): setattr(self, name, forms.Slider()) setattr(getattr(self, name), 'Value', 1) setattr(getattr(self, name), 'MinValue', 0) setattr(getattr(self, name), 'MaxValue', 10) setattr(getattr(self, name), 'ValueChanged', getattr(getattr(self, name), 'ValueChanged')+self.onvaluechanged)
however python doesn’t allow me to set the ValueChanged attribute like this
the original one should be:
self.myslider.ValueChanged += self.onvaluechanged
The error is:
Runtime error (TypeErrorException): unsupported operand type(s) for +: ‘BoundEvent’ and ‘instancemethod’
line 25, in addnumeric, “”
line 28, in init, “”
line 45, in script
Actually, I don’t know how this line works.
The Idea is to create multiple sliders within the init function so that i don’t have to repeat myself.
Could anyone explain the idea of the line or give me some other ways to do this?