Reputation: 67
I have two images for the background a button, One of the images is the default image of the button, I want to change the background image of button, when I click it. This is my code:
class Control_(Screen):
Status = 0
print(Status)
def StatusButton(self):
if self.Status == 0:
self.Status = 1
print(self.Status)
elif self.Status == 1:
self.Status = 0
print(self.Status)
and *.kv is:
<Control_>:
Button:
background_normal: "on.png"
size_hint: .3, .2
pos_hint: {"x":.3, "y":.3}
on_release:root.StatusButton()
Upvotes: 1
Views: 486
Reputation: 368
try that
<Control_>:
Button:
background_normal: "on.png"
size_hint: .3, .2
pos_hint: {"x":.3, "y":.3}
on_release:self.background_normal="on.png" if background_normal=="off.png" else "off.png"
Upvotes: 2