How to set a screen background image in Kivy

前端 未结 1 629
说谎
说谎 2021-01-02 04:05

I know how to make a color background but i can\'t seem to find anything useful for setting the image as a background and would be really grateful for any help with my code.

相关标签:
1条回答
  • 2021-01-02 04:11
    canvas.before:
            Rectangle:
                pos: self.pos
                size: self.size
            Image:
                source: "lights.png"
    

    Image is a widget, you can't place it on the canvas.

    What you *can do is either just set a source for the Rectangle:

    canvas.before:
            Rectangle:
                pos: self.pos
                size: self.size
                source: 'lights.png'
    

    ...or place your Image behind the other widgets by putting them in a container layout.

    0 讨论(0)
提交回复
热议问题