for j in range(len(Lights.lights)):
i = j
button = Button(
text = Lights.lights[i][2], font_size = 24,
text_size = (160,60),
halign = 'center', valign = 'center',
size_hint_x = None, width = 188,
size_hint_y = None, height = 68,
id=str(i),
color = black,
background_normal = '',
background_color = grey,
on_press = self.on_event
)
self.mylights.append([grey,button])
grid.add_widget(button)
def on_event(self, obj):
import Lights
objid = int(obj.id)
Lights.lights[objid][1].toggle()
self.mylights[objid][0] = grey
if (Lights.lights[objid][1].read()):
self.mylights[objid][0] = yellow
obj.background_color = self.mylights[objid][0]
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
id may not be a button property, but so what? Add it as an attribute and use it later. That's what I usually do in these situations.button = Button(some_parameters)button.id = i