# Display Text in Slice view

**URL:** <https://discourse.slicer.org/t/display-text-in-slice-view/13264>\
**Category:** Development\
**Created:** [August 31, 2020, 7:42pm UTC](https://discourse.slicer.org/t/display-text-in-slice-view/13264 "2020-08-31T19:42:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidCai1246](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@DavidCai1246](https://discourse.slicer.org/u/DavidCai1246)\
**Post date:** [August 31, 2020, 7:42pm UTC](https://discourse.slicer.org/t/display-text-in-slice-view/13264/1 "2020-08-31T19:42:21Z")

</div>

I’m would like to display unique text in the slice view for each slice.

I’m currently trying to use the python script to display text in slice view:

```
view=slicer.app.layoutManager().threeDWidget(0).threeDView()
# Set text to "Something"
view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,"Something")
# Set color to red
view.cornerAnnotation().GetTextProperty().SetColor(1,0,0)
# Update the view
view.forceRender()

```

However nothing shows up, do I have to enable something?

Another question I have is would this script display the same text for all the slices? So if I scroll through the slices it would be the same text? How can I display unique text for each slice?

---

<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:** [August 31, 2020, 8:05pm UTC](https://discourse.slicer.org/t/display-text-in-slice-view/13264/2 "2020-08-31T20:05:35Z")

</div>

The code above works well for me - displays text in 3D view as expected.

To display text in slice views, replace the first line by this line:

```
view = slicer.app.layoutManager().sliceWidget("Red").sliceView()

```

You may consider hiding slice view annotations, to prevent them from overwriting the text you place there. See [example](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Hide_slice_view_annotations_.28DataProbe.29).

---

<div class="post-metadata">

**Author:** ![DavidCai1246](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@DavidCai1246](https://discourse.slicer.org/u/DavidCai1246)\
**Post date:** [August 31, 2020, 8:18pm UTC](https://discourse.slicer.org/t/display-text-in-slice-view/13264/3 "2020-08-31T20:18:30Z")

</div>

thank you very much! it displays for me now

---

<div class="post-metadata">

**Author:** ![DavidCai1246](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@DavidCai1246](https://discourse.slicer.org/u/DavidCai1246)\
**Post date:** [August 31, 2020, 9:00pm UTC](https://discourse.slicer.org/t/display-text-in-slice-view/13264/4 "2020-08-31T21:00:42Z")

</div>

Sorry one more question I have is, can I change the font size of the text? like make it bigger?

---

<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:** [August 31, 2020, 9:17pm UTC](https://discourse.slicer.org/t/display-text-in-slice-view/13264/5 "2020-08-31T21:17:00Z")

</div>

Yes, sure, see how the text is scaled by DataProbe:

> <https://github.com/Slicer/Slicer/blob/77d4268cd3659d452d8e5a7748cd20f456771b48/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py#L451-L453>

---

<div class="post-metadata">

**Author:** ![DavidCai1246](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@DavidCai1246](https://discourse.slicer.org/u/DavidCai1246)\
**Post date:** [August 31, 2020, 9:17pm UTC](https://discourse.slicer.org/t/display-text-in-slice-view/13264/6 "2020-08-31T21:17:56Z")

</div>

thank you very much!!
