按钮释放事件在Kivy中不起作用

时间:2014-03-26 19:12:49

标签: python kivy

问题是我可以在按下按钮时触发事件,但按钮释放不起作用;这是我的.kv代码:

Button:
    id: my_custom_label
    text: 'SOS'
    height: "95dp"
    width: "160dp"
    on_press: app.sendprogress()   # this is working
    on_release : app.sendhelp()    # this is not working
    size_hint: None, None
    pos_hint: {'center_x': .1, 'center_y': .1}
    canvas.before:
        PushMatrix
        Rotate:
            angle: 0
            origin: self.center
    canvas.after:
        PopMatrix

我看到的错误是:

32:               on_press: app.sendprogress()
>> 33:               on_release : app.sendhelp()
34:               size_hint: None, None
35:        pos_hint: {'center_x': .1, 'center_y': .1}
...
Invalid property name

1 个答案:

答案 0 :(得分:3)

尝试删除冒号前的空格:即代替on_release : app.sendhelp()执行on_release: app.sendhelp()。我认为你不允许在那里有空间。