Eric MacLeod
Eric MacLeod

Reputation: 461

How can I resize and position a widget in the kv language?

I'm trying to resize an image so it's in the left corner, I've been playing around with it and I can't get my head around this code works, before I put it in the left corner I want to resize to size of the green rectangle to just see how it works but I'm not getting that.

enter image description here

#:kivy 1.9.0
GridLayout:
    rows: 1

    LeftArea:
    RightArea:

<LeftArea@FloatLayout>:

    canvas:
        Color:
            rgb: 0, 1, 0
        Rectangle:
            size: self.size
            pos: self.pos
    Image:
        source: 'moneyswags.gif'
        size: self.size
        pos: self.pos

Upvotes: 0

Views: 393

Answers (1)

jligeza
jligeza

Reputation: 4693

Everything you need is written here: Image

Add allow_stretch: True to the image, and it will cover the entire parent float layout.

Also, defining size: self.size and pos: self.pos inside the Image does nothing. In case of canvas, self refers to the widget on which you are drawing (in this case, float layout).

Upvotes: 1

Related Questions