Resize vtkCaptionRepresentation Box

Hello,
I want to resize the boundarybox that is attached to the vtkCaptionRepresentation. When I display too much text despite increasing the font size, the text is very small, as the boundary box does not change its size. When you turn off the display of the border, the text will enlarge and is as it should be. What methods should I use to adjust the border dynamically?

Hello,

Can you, please, share the code?

best,

PC

No problem, i used this example and rewrite to python:
https://examples.vtk.org/site/Cxx/Widgets/CaptionWidget/

import vtkmodules.all as vtk

# Renderer Background Color
bg_color = [1.0, 0.0, 0.0, 1.0]  # Red

# Sphere
sphere_source = vtk.vtkSphereSource()
sphere_source.Update()

# Create a mapper and actor
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(sphere_source.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)

# Create the renderer, render window, and interactor
ren = vtk.vtkRenderer()
ren_win = vtk.vtkRenderWindow()
ren_win.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(ren_win)

# Create the widget and its representation
caption_representation = vtk.vtkCaptionRepresentation()
caption_representation.GetCaptionActor2D().SetCaption("Test Caption")
caption_representation.GetCaptionActor2D().GetTextActor().GetTextProperty().SetFontSize(500)
caption_representation.GetCaptionActor2D().GetTextActor().SetMinimumSize(100, 100)
# caption_representation.GetCaptionActor2D().BorderOff()
caption_representation.ProportionalResizeOn()
# caption_representation.SetMinimumSize(1000, 10000)

pos = [0.5, 0, 0]
caption_representation.SetAnchorPosition(pos)

caption_widget = vtk.vtkCaptionWidget()
caption_widget.SetInteractor(iren)
caption_widget.SetRepresentation(caption_representation)

ren.AddActor(actor)

ren_win.SetSize(300, 300)
ren_win.Render()
caption_widget.On()

iren.Initialize()
iren.Start()

I also tried to done custom interactor style, however, it worked the same way in terms of border size.

.SetTextScaleModeToNone()

This method scales only the text and borderbox horizontally, when adding a new line of text ā€œ\nā€ the height does not change and the text gets smaller and smaller

Here are examples: