# Question about how to make a fixation cross appear for various durations

**URL:** <https://discourse.psychopy.org/t/question-about-how-to-make-a-fixation-cross-appear-for-various-durations/3461>\
**Category:** Coding\
**Created:** [November 16, 2017, 9:33pm UTC](https://discourse.psychopy.org/t/question-about-how-to-make-a-fixation-cross-appear-for-various-durations/3461 "2017-11-16T21:33:18Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [November 18, 2017, 6:35am UTC](https://discourse.psychopy.org/t/question-about-how-to-make-a-fixation-cross-appear-for-various-durations/3461/3 "2017-11-18T06:35:08Z")

</div>

> [@Csg](#):
>
> I have been working with the builder view but am trying to go back to the coder view to change the code.

Don’t do that. There is a far better alternative:

> [@Error in importing .xlsx conditions file](https://discourse.psychopy.org/t/error-in-importing-xlsx-conditions-file/3464/4):
>
> This is unlikely to be necessary. Keep working in Builder and insert code components within the Builder interface rather than attempting to edit the generated script. The code component will automatically insert the code at the right place (beginning of experiment, beginning of routine, every frame, etc) and allows you to keep tweaking the experiment using the GUI. Best of both worlds. This is a feature rather than a bug. i.e. can you think of a better way that PsychoPy should search for your…

For a simple task like this, you could actually just embed a random function as @schubisu suggests , directly in the onset field of your stimulus, with a `$` prefix to indicate that it is code. But you will probably also want to save that value in the data, which requires another line of code. So insert a code component, put it above the text stimulus so that it updates the variable before the text stimulus needs to refer to it, and put in something like this in the `Begin Routine` tab:

```auto
fixation_start_time = np.random.choice([0.5, 1.0, 2.0])
thisExp.addData('fixation_start_time', fixation_start_time)

```

and then put `$fixation_start_time` in the stimulus onset field, set to update every routine.

---

_[View the full topic](https://discourse.psychopy.org/t/question-about-how-to-make-a-fixation-cross-appear-for-various-durations/3461)._
