Reputation: 5
When I use default code for screenmanager to switch between the screens it works:
<MainWindow>:
name:'Main'
BoxLayout:
orientation:'horizontal'
size: root.width, root.height
Button:
text:'Hello'
font_size:32
color:1,1,1,1
on_press:
app.root.current='second'
root.manager.transition.direction = 'right'
***BUT when I change source so that the button is an image, loaded from the same folder and run it, I get this:
<MainWindow>:
name:'Main'
BoxLayout:
orientation:'horizontal'
size: root.width, root.height
Button:
#text:'Hello'
#font_size:32
#color:1,1,1,1
Image:
source:'photo.png'
on_press:
app.root.current='second'
root.manager.transition.direction = 'right'
>> 29: app.root.current='second'
30: root.manager.transition.direction = 'right'
31:
...
Invalid property name
Upvotes: 0
Views: 30
Reputation: 38962
If you want to use an Image
as a Button
, you can extend the Image
class with ButtonBehavior
. See the documentation.
Or, you can use the properties of the Button
. See the documentation, like this:
Button:
#text:'Hello'
#font_size:32
#color:1,1,1,1
background_normal: 'photo.png'
# Image:
# source:'photo.png'
on_press:
app.root.current='second'
root.manager.transition.direction = 'right'
Upvotes: 1