Why do these two blocks yield different results in kivy?
size
size: [50,50]
size_x and size_y
size_x: 50
size_y: 50
Example
For example, the following code does not render the same looking app
size
Using just size has more padding around the label
#!/usr/bin/env python3
from kivy.uix.button import Button
from kivy.lang import Builder
from kivy.app import App
KV = """
StackLayout:
orientation: 'lr-tb'
Label:
text: "Hello"
size: [50,50]
size_hint: None, None
Label:
text: "World"
size: self.texture_size
size_hint: None, None
"""
class MyApp(App):
def build(self):
return Builder.load_string( KV )
size_x and size_y
Using both size_x and size_y has less padding around the label
#!/usr/bin/env python3
from kivy.uix.button import Button
from kivy.lang import Builder
from kivy.app import App
KV = """
StackLayout:
orientation: 'lr-tb'
Label:
text: "Hello"
size_x: 50
size_y: 50
size_hint: None, None
Label:
text: "World"
size: self.texture_size
size_hint: None, None
"""
class MyApp(App):
def build(self):
return Builder.load_string( KV )
My understanding is that size is merely a python list of [size_x, size_y]. Because of this, I'd expect that declaring them separately would yield the same results.
Why does declaring size as distinct size_x and size_y variables differ from declaring it just once with size?


size_xandsize_ydoesn't exist at all in the Kivy's API, and in the Kivy widget attributes.sizeis a reference to a list of[width, height]. Theses code are identicals:is equal to:
Your example have a different behavior because the default size of a unconstrained Widget is
100, 100. So assigningsize_xandsize_yare meaningless.