Hello all,
I'm always having troubles with sizes in Kivy.
Now I want to retrieve the size of a FloatLayout (to add dynamically objets in it).
The size I get is always the default one: (100,100)
For this program
-----------
from kivy.app import App
from kivy.lang import Builder
kv = """
BoxLayout:
orientation: "vertical"
canvas:
Color:
rgb: 1, .7, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text:"Titre"
color: 0, 0, 0
size_hint: 1, 0.1
FloatLayout:
id: flt
canvas:
Color:
rgb: 0.5, 1, 0.5
Rectangle:
pos: self.pos
size: self.size
Button:
id: btn
size_hint: None, None
size: 95, 95
"""
class main(App):
def build(self):
return Builder.load_string(kv)
def on_start(self, **kwargs):
print (self.root.ids.flt.size)
print (self.root.ids.btn.size)
if (__name__ == "__main__"):
main().run()
--------
I can see the button, which size (95, 95), and the FloatLayout, in green.
The floatLayout is very big comparatively to the button, but the console output is
[100, 100]
[95, 95]
How can I retrieve the good information?