@@ -273,8 +273,10 @@ def shift_brace(self, obj: Mobject, **kwargs: Any) -> Self:
273
273
return self
274
274
275
275
def change_label (self , * text : str , ** kwargs : Any ) -> Self :
276
+ self .remove (self .label )
276
277
self .label = self .label_constructor (* text , ** kwargs ) # type: ignore[arg-type]
277
278
self .brace .put_at_tip (self .label )
279
+ self .add (self .label )
278
280
return self
279
281
280
282
def change_brace_label (self , obj : Mobject , * text : str , ** kwargs : Any ) -> Self :
@@ -284,6 +286,50 @@ def change_brace_label(self, obj: Mobject, *text: str, **kwargs: Any) -> Self:
284
286
285
287
286
288
class BraceText (BraceLabel ):
289
+ """Create a brace with a text label attached.
290
+
291
+ Parameters
292
+ ----------
293
+ obj
294
+ The mobject adjacent to which the brace is placed.
295
+ text
296
+ The label text.
297
+ brace_direction
298
+ The direction of the brace. By default ``DOWN``.
299
+ label_constructor
300
+ A class or function used to construct a mobject representing
301
+ the label. By default :class:`~.Text`.
302
+ font_size
303
+ The font size of the label, passed to the ``label_constructor``.
304
+ buff
305
+ The buffer between the mobject and the brace.
306
+ brace_config
307
+ Arguments to be passed to :class:`.Brace`.
308
+ kwargs
309
+ Additional arguments to be passed to :class:`~.VMobject`.
310
+
311
+
312
+ Examples
313
+ --------
314
+ .. manim:: BraceTextExample
315
+ :save_last_frame:
316
+
317
+ class BraceTextExample(Scene):
318
+ def construct(self):
319
+ s1 = Square().move_to(2*LEFT)
320
+ self.add(s1)
321
+ br1 = BraceText(s1, "Label")
322
+ self.add(br1)
323
+
324
+ s2 = Square().move_to(2*RIGHT)
325
+ self.add(s2)
326
+ br2 = BraceText(s2, "Label")
327
+
328
+ br2.change_label("new")
329
+ self.add(br2)
330
+ self.wait(0.1)
331
+ """
332
+
287
333
def __init__ (
288
334
self ,
289
335
obj : Mobject ,
0 commit comments