2014-03-26 27 views
0

問題是,當按下按鈕時我可以觸發事件,但按鈕釋放不起作用;這裏是我的.kv代碼:按鈕釋放事件在Kivy中不起作用

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 
+0

我們可以看到'sendhelp()'方法嗎? – IanAuld

回答

3

嘗試刪除冒號前的空間:即代替on_release : app.sendhelp()on_release: app.sendhelp()。我認爲你不能在那裏有空間。

+0

謝謝。我不知道空間是不允許的,我正在考慮一些邏輯錯誤。 –