# Drawing a border around TextStim?

**URL:** <https://discourse.psychopy.org/t/drawing-a-border-around-textstim/1799>\
**Category:** Coding\
**Created:** [January 24, 2017, 12:16am UTC](https://discourse.psychopy.org/t/drawing-a-border-around-textstim/1799 "2017-01-24T00:16:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Natalia](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@Natalia](https://discourse.psychopy.org/u/Natalia)\
**Post date:** [January 24, 2017, 12:16am UTC](https://discourse.psychopy.org/t/drawing-a-border-around-textstim/1799/1 "2017-01-24T00:16:14Z")

</div>

In Coder, is there some way to draw a border around a TextStim after it’s been created? I have two TextStim on the page indicating the two possible responses the participant can make, and I want a border to appear around the option chosen by the participant.

Hope that makes sense—thanks in advance for your help!

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [January 24, 2017, 1:25am UTC](https://discourse.psychopy.org/t/drawing-a-border-around-textstim/1799/2 "2017-01-24T01:25:43Z")

</div>

Yes, you can just use a `Rect` stimulus ([http://www.psychopy.org/api/visual/rect.html#psychopy.visual.Rect](http://www.psychopy.org/api/visual/rect.html#psychopy.visual.Rect)).

If the contents of your text stimuli change from trial to trial, then you can use the `boundingBox` attribute of your text stimulus to update the size of the rectangle as required ([http://www.psychopy.org/api/visual/textstim.html](http://www.psychopy.org/api/visual/textstim.html)).

---

<div class="post-metadata">

**Author:** ![Natalia](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@Natalia](https://discourse.psychopy.org/u/Natalia)\
**Post date:** [January 24, 2017, 8:04pm UTC](https://discourse.psychopy.org/t/drawing-a-border-around-textstim/1799/3 "2017-01-24T20:04:38Z")

</div>

Thank you, that works great! Just to clarify: I placed a Rect stimulus below my TextStim, but is there another way to place text inside the Rect stimulus?

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [January 25, 2017, 1:46am UTC](https://discourse.psychopy.org/t/drawing-a-border-around-textstim/1799/4 "2017-01-25T01:46:20Z")

</div>

I’m not really sure what the issue is? i.e. Just give the rect stimulus the same location as the text stimulus, and the same size ( or scaled slightly larger), and it should appear as desired (i.e. the text will appear inside the rectangle).

Perhaps I’ve misunderstood something, so perhaps post a diagram of the current result and what you want to achieve…

---

<div class="post-metadata">

**Author:** ![Natalia](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@Natalia](https://discourse.psychopy.org/u/Natalia)\
**Post date:** [February 1, 2017, 12:28am UTC](https://discourse.psychopy.org/t/drawing-a-border-around-textstim/1799/5 "2017-02-01T00:28:02Z")

</div>

Oops, sorry for being unclear! I was just wondering whether it was possible to draw a single “Text Box” stimulus, like a TextStim that can also have a border and a background, instead of drawing two separate stimuli on top of one another. But draw a Rect and TextStim separately works well. Thanks again!
