I am using vtkCaptionActor2D
in my project, and I can not specify its’ background color.
The minimal code to reproduce my question is:
import vtkmodules.all as vtk
line = vtk.vtkLineSource()
line.SetPoint1(0, 0, 0)
line.SetPoint2(1, 1, 1)
line.Update()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(line.GetOutput())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
render = vtk.vtkRenderer()
render.AddActor(actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(render)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
captionActor = vtk.vtkCaptionActor2D()
captionActor.SetCaption('caption')
captionActor.SetAttachmentPoint(1, 1, 1)
property = captionActor.GetCaptionTextProperty()
property.SetBackgroundColor(1, 0, 0)
render.AddActor(captionActor)
iren.Initialize()
iren.Start()
But the background color do not change:
I also tried captionActor.GetTextActor().GetTextProperty().SetBackgroundColor(1, 0, 0)
, but it still do not work.
Any suggestion is appreciated~~~