How do I insert an image by pressing a button? Kivy

Viewed 34

I think the title explains the question well. I want a small image (from the folder) to be inserted when I press a button. I would be excited to receive answers. Thank you and best regards

1 Answers

I think this should work... i did it at my job so i didn't get a chance to test it.

kv = '''
<MyScreen>
    BoxLayout:
        id: myimage
        orientation: 'vertical'

        MDButton:
            text: 'button'
            on_release: add_image() 
'''        
        


class MyScreen(MDScreen):
    image = StringProperty()

    def add_image(self)
        self.ids.myimage.add_widget(FitImage(
            source= 'image.png'
        ))
Related