Skip to content

Commit d9fa743

Browse files
committed
doc: Corrected and improved size_hint doc
1 parent 91d61d4 commit d9fa743

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

kivy/uix/widget.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,21 @@ def set_center_y(self, value):
961961
Only the :class:`~kivy.uix.layout.Layout` and
962962
:class:`~kivy.core.window.Window` classes make use of the hint.
963963
964-
The value is in percent as a float from 0. to 1., where 1. means the full
965-
size of his parent. 0.5 represents 50%.
964+
The size_hint is used by layouts for two purposes:
965+
966+
- When the layout considers widgets on their own rather than in
967+
relation to its other children, the size_hint_x is a direct proportion
968+
of the parent width, normally between 0.0 and 1.0. For instance, a
969+
widget with ``size_hint_x=0.5`` in
970+
a vertical BoxLayout will take up half the BoxLayout's width, or
971+
a widget in a FloatLayout with ``size_hint_x=0.2`` will take up 20%
972+
of the FloatLayout width. If the size_hint is greater than 1, the
973+
widget will be wider than the parent.
974+
- When multiple widgets can share a row of a layout, such as in a
975+
horizontal BoxLayout, their widths will be their size_hint_x as a
976+
fraction of the sum of widget size_hints. For instance, if the
977+
size_hint_xs are (0.5, 1.0, 0.5), the first widget will have a
978+
width of 25% of the parent width.
966979
967980
:attr:`size_hint_x` is a :class:`~kivy.properties.NumericProperty` and
968981
defaults to 1.
@@ -974,7 +987,8 @@ def set_center_y(self, value):
974987
:attr:`size_hint_y` is a :class:`~kivy.properties.NumericProperty` and
975988
defaults to 1.
976989
977-
See :attr:`size_hint_x` for more information.
990+
See :attr:`size_hint_x` for more information, but with widths and heights
991+
swapped.
978992
'''
979993

980994
size_hint = ReferenceListProperty(size_hint_x, size_hint_y)

0 commit comments

Comments
 (0)