Caridorc Caridorc - 15 days ago 7
Python Question

Size of canvas in kivy

In my app I need to know how big the canvas is in pixels.

Instead calling

canvas.size
returns
[100,100]
no matter how many pixels the canvas is wide.

Can you please tell me a way to get how many pixels the canvas is wide and high?

Answer

There is no position nor size in a Canvas. Canvas act just as a container for graphics instructions, like Fbo that draw within a Texture, so it have a size.

In Kivy, Canvas.size doesn't exists, but i guess you called your widget a canvas. By default, a Widget size is 100, 100. If you put it into a layout, the size will be changed, when the layout will known its own size. Mean, you need to listen to the changes of the Widget.size, or use a size you known, like Window.size.

Comments