Changing Toggle Button Image

214 views
Skip to first unread message

KivyNoob

unread,
Mar 17, 2021, 10:20:06 PM3/17/21
to Kivy users support
Hello, I'm creating a simple program that has a toggle button with an image. When the button is pressed I want the image to change. I don't know how to do this and was wondering if anyone could help me? Below is my code. Thanks.

python file:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout

class main(BoxLayout):
    pass


presentation = Builder.load_file("toggle.kv")

class ToggleApp(App):
    def build(self):
        return presentation
    
    
if __name__== "__main__":
    toggle().run()

kv file:

<main>:

    ToggleButton:
        id: tbtn
        Image:

            source: '/home/pi/Desktop/toggle/icons/light.png'
            center_x: self.parent.center_x
            center_y: self.parent.center_y

Elliot Garbus

unread,
Mar 17, 2021, 11:21:50 PM3/17/21
to kivy-...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d668b195-f8c7-47fc-91d0-4f198e4557f3o%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages