File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,7 @@ class UILabel(UIWidget):
6464 ``multiline`` of True is the same thing as
6565 a :py:class:`~arcade.gui.UITextArea`.
6666 :param size_hint: A tuple of floats between 0 and 1 defining the amount of
67- space of the parent should be requested.
68- :param size_hint_min: Minimum size hint width and height in pixel.
67+ space of the parent should be requested. Default (0, 0) which fits the content.
6968 :param size_hint_max: Maximum size hint width and height in pixel.
7069 :param style: Not used. Labels will have no need for a style; they are too
7170 simple (just a text display).
@@ -86,8 +85,7 @@ def __init__(
8685 italic = False ,
8786 align = "left" ,
8887 multiline : bool = False ,
89- size_hint = None ,
90- size_hint_min = None ,
88+ size_hint = (0 , 0 ),
9189 size_hint_max = None ,
9290 ** kwargs ,
9391 ):
@@ -125,7 +123,6 @@ def __init__(
125123 width = width or self .label .content_width ,
126124 height = height or self .label .content_height ,
127125 size_hint = size_hint ,
128- size_hint_min = size_hint_min ,
129126 size_hint_max = size_hint_max ,
130127 ** kwargs ,
131128 )
Original file line number Diff line number Diff line change @@ -99,3 +99,14 @@ def test_change_text_does_normal_render_with_background(window):
9999
100100 label .text = "Second Text"
101101 label .parent .trigger_render .assert_not_called ()
102+
103+
104+ def test_uilabel_automatically_fit_content (uimanager ):
105+ label = UILabel (text = "First Text" )
106+ uimanager .add (label )
107+ start_width = label .rect .width
108+
109+ label .text = "Second Text, which is way longer"
110+ uimanager .execute_layout ()
111+
112+ assert label .rect .width > start_width
You can’t perform that action at this time.
0 commit comments