Is there a way to change shape of an image that is used as button's background? First, I was using this .kv code:
Button:
id: button
size_hint: None, None
background_color: (0, 0, 0, 0)
pos: (root.width - self.width) / 2, (root.top - self.height) / 2 + self.height + 100
size: 750, 500
on_press: main.button_on_press()
on_release: main.button_on_release()
canvas.before:
RoundedRectangle:
pos: self.pos
size: self.size
radius: [100]
source: "Button.png"
And the Python functions were:
def button_on_press(self):
self.ids.button.source = "Button_pressed.png"
def button_on_release(self):
self.ids.button.source = "Button.png"
But that didn't work. I didn't find any way to change the source from the Python code. If there is any way, please tell me.
Then I changed the .kv code to this:
Button:
id: button
size_hint: None, None
background_color: (0, 0, 0, 0)
pos: (root.width - self.width) / 2, (root.top - self.height) / 2 + self.height + 100
size: 750, 500
on_press: main.button_on_press()
on_release: main.button_on_release()
Image:
id: image
size: 750, 500
source: "Button.png"
pos: (root.width - self.width) / 2, (root.top - self.height) / 2 + self.height + 100
Now the Python functions looked like:
def button_on_press(self):
self.ids.image.source = "Button_pressed.png"
def button_on_release(self):
self.ids.image.source = "Button.png"
But can I now change the shape of the image? (Like RoundedRectangle)