# Why fontSize of vtkTextActor() not working as setup-values (via Python)?

**URL:** <https://discourse.slicer.org/t/why-fontsize-of-vtktextactor-not-working-as-setup-values-via-python/15901>\
**Category:** Development\
**Created:** [February 8, 2021, 4:57pm UTC](https://discourse.slicer.org/t/why-fontsize-of-vtktextactor-not-working-as-setup-values-via-python/15901 "2021-02-08T16:57:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aiden.zhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aiden.zhu/32/67145_2.png) [@aiden.zhu](https://discourse.slicer.org/u/aiden.zhu)\
**Post date:** [February 8, 2021, 4:57pm UTC](https://discourse.slicer.org/t/why-fontsize-of-vtktextactor-not-working-as-setup-values-via-python/15901/1 "2021-02-08T16:57:36Z")

</div>

Operating system: Windows  
Slicer version: 4.11.0-2019-06-23 r28335  
Expected behavior: font-size adjustment  
Actual behavior: X

Hi All, I tried to use vtk.vtkTextActor() to set up a text-info in a window as in the following code, but The fontsize did not change as expected, instead it showed as the original size (12). Why? Thanks a lot in advance!

```python
lm = slicer.app.layoutManager()
layout = lm 
import os 
redRenderer = layout.sliceWidget('Red').sliceView().renderWindow().GetRenderers().GetFirstRenderer()
redRenderWindow = redRenderer.GetRenderWindow()
redRenderWindow.Render()
vn_red = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')
slicer.app.layoutManager().layout = 6
sliceLogic = lm.sliceWidget(vn_red.GetLayoutName()).sliceLogic()
originalSliceOffset = sliceLogic.GetSliceOffset()
interactor = redRenderWindow.GetInteractor()
text = vtk.vtkTextActor()
text.SetInput('Testing Info Text')
textProperty = text.GetTextProperty()
print('Before changing = ', textProperty.GetFontSize())
fontsize_text = 60
textProperty.SetFontSize(fontsize_text)
print('After Changing = ', textProperty.GetFontSize())
textProperty.SetColor(1, 1, 0)
textProperty.SetBold(1)
text_representation = vtk.vtkTextRepresentation()
text_representation.GetPositionCoordinate().SetValue( 0.025, 0.92850 )
text_widget = vtk.vtkTextWidget(); 
text_widget.SetRepresentation(text_representation)
text_widget.SetInteractor(interactor); 
text_widget.SetTextActor(text);text_widget.SelectableOff()
text_widget.EnabledOn(); text_widget.On()
slicer.app.processEvents()

```

Aiden

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 8, 2021, 9:01pm UTC](https://discourse.slicer.org/t/why-fontsize-of-vtktextactor-not-working-as-setup-values-via-python/15901/2 "2021-02-08T21:01:44Z")

</div>

If you put your text actor into a vtkTextWidget then the text widget will take care of the font size. You can make the text bigger by clicking the edge or corner of the textbox and drag it to make it larger.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/7/07653011603e057df96105d05e79ee154c25b6ba.jpeg)

---

<div class="post-metadata">

**Author:** ![aiden.zhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aiden.zhu/32/67145_2.png) [@aiden.zhu](https://discourse.slicer.org/u/aiden.zhu)\
**Post date:** [February 17, 2021, 8:12pm UTC](https://discourse.slicer.org/t/why-fontsize-of-vtktextactor-not-working-as-setup-values-via-python/15901/3 "2021-02-17T20:12:27Z")

</div>

Thanks, Andras.  
I know that dragging works there. What I would expect is that I would like to control it by user-GUI to adjust/input a number as needed.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 17, 2021, 8:20pm UTC](https://discourse.slicer.org/t/why-fontsize-of-vtktextactor-not-working-as-setup-values-via-python/15901/4 "2021-02-17T20:20:35Z")

</div>

The text actor does now know that it is embedded in a text widget, so if you want to modify the text size then you have to do it in the widget. Maybe simply calling [ResizableOff](https://vtk.org/doc/nightly/html/classvtkBorderWidget.html#aec722ff199d9ef7db3ee580f37e1db81) on the widget is sufficient, but if not then you need to check out the implementation and maybe you’ll have to add a two-way synchronization mechanism between the widget and the actor.

Why do you need a custom widget? You can use markups fiducials to display labels in slice and 3D views.
