@@ -110,6 +110,7 @@ def __init__(
110
110
self ._text_scale = []
111
111
self ._text_font = []
112
112
self ._text_line_spacing = []
113
+ self ._text_anchor_point = []
113
114
114
115
gc .collect ()
115
116
@@ -124,6 +125,7 @@ def add_text(
124
125
text_transform = None ,
125
126
text_scale = 1 ,
126
127
line_spacing = 1.25 ,
128
+ text_anchor_point = (0 , 0.5 ),
127
129
):
128
130
"""
129
131
Add text labels with settings
@@ -153,6 +155,10 @@ def add_text(
153
155
text_transform = None
154
156
if not isinstance (text_scale , (int , float )) or text_scale < 1 :
155
157
text_scale = 1
158
+ if not isinstance (text_anchor_point , (tuple , list )):
159
+ text_anchor_point = (0 , 0.5 )
160
+ if not 0 <= text_anchor_point [0 ] <= 1 or not 0 <= text_anchor_point [1 ] <= 1 :
161
+ raise ValueError ("Text anchor point values should be between 0 and 1." )
156
162
text_scale = round (text_scale )
157
163
gc .collect ()
158
164
@@ -166,6 +172,7 @@ def add_text(
166
172
self ._text_transform .append (text_transform )
167
173
self ._text_scale .append (text_scale )
168
174
self ._text_line_spacing .append (line_spacing )
175
+ self ._text_anchor_point .append (text_anchor_point )
169
176
170
177
# pylint: enable=too-many-arguments
171
178
@@ -255,8 +262,8 @@ def set_text(self, val, index=0, auto_refresh=True):
255
262
self ._text_font [index ], text = string , scale = self ._text_scale [index ]
256
263
)
257
264
self ._text [index ].color = self ._text_color [index ]
258
- self ._text [index ].x = self ._text_position [index ][ 0 ]
259
- self ._text [index ].y = self ._text_position [index ][ 1 ]
265
+ self ._text [index ].anchor_point = self ._text_anchor_point [index ]
266
+ self ._text [index ].anchored_position = self ._text_position [index ]
260
267
self ._text [index ].line_spacing = self ._text_line_spacing [index ]
261
268
elif index_in_splash is not None :
262
269
self ._text [index ] = None
0 commit comments