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!
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