There are two errors in your code. the first one is that you have given the event handlers and the buttons the same name. So change one of those. Second, you need a second parameter to event handlers as it gets called with a parameter.
Here is your corrected code:
class Layout(FloatLayout):
def __init__(self, **kwargs):
super(Layout, self).__init__(**kwargs)
self.size = Window.size
self.play = Button(text="Play", size_hint=(0.25, 0.25), font_size=36,
pos=(self.size[0]*(3/8), self.size[1]*(4/10)) )
self.pause = Button(text="Pause", size_hint=(0.25, 0.25), font_size=36,
pos=(self.size[0]*(3/8), self.size[1]*(1/10)) )
self.play.bind(on_press=self.play1)
self.pause.bind(on_press=self.pause1)
self.add_widget(self.play)
self.add_widget(self.pause)
def play1(self, instance):
print("PLay")
def pause1(self, instance):
print("Pause")
If you don't want to add a parameter then you can use lambda function.
Something like this:
self.play.bind(on_press=lambda _:self.play1())
self.pause.bind(on_press=lambda _:self.pause1())
In this case, you can remove the extra parameter in the eventhandler.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…