Can I add more than one behaviour in widgets in Kivy?

sairam kumar :

Questions:

  • Can I add more than one behaviour in widgets in Kivy?

Code:

<ImageButton@ButtonBehavior@HoverBehavior+Image>

<MyClass>:
    BoxLayout:
        orientation: "vertical"
        ImageButton:
            source: "C:\\Users\\kanna\\Pictures\\OpenCity-Main_Menu\\PNG\\NewGame.png"
            on_press:
                self.source = "C:\\Users\\kanna\\Pictures\\OpenCity-Main_Menu\\PNG\\NewGameClick.png"
            on_release:
                self.source = "C:\\Users\\kanna\\Pictures\\OpenCity-Main_Menu\\PNG\\NewGame.png"

Thanking You!!

Werty Laura :

You can use the Erik's comment like this!

<ImageButton@ButtonBehaviour+HoverBehavior+Image>

<MyClass>:
    BoxLayout:
        orientation: "vertical"
        ImageButton:
            source: "C:\\Users\\kanna\\Pictures\\OpenCity-Main_Menu\\PNG\\NewGame.png"
            on_press:
                self.source = "C:\\Users\\kanna\\Pictures\\OpenCity-Main_Menu\\PNG\\NewGameClick.png"
            on_release:
                self.source = "C:\\Users\\kanna\\Pictures\\OpenCity-Main_Menu\\PNG\\NewGame.png"

Remove the second @ and replace with +!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=336629&siteId=1