Code changes from Builder view don't save

682 views
Skip to first unread message

Jack Keegan

unread,
Mar 29, 2012, 6:23:31 PM3/29/12
to psychop...@googlegroups.com
Hi there,

I've had PsychoPy2 installed for a while but just getting round to using it now. However, when I try to create and experiment using builder and then hit 'compile script' it brings up the code editor. If I make changes here, it doesn't seem to save. I can run the changes from here and they will take effect. However, if I save and close this code editor, I lose all my changes. Is this normal behavior?

Cheers,

Jack

--
The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot.
- Carl Sagan [Pale Blue Dot]

Michael MacAskill

unread,
Mar 29, 2012, 9:17:56 PM3/29/12
to psychop...@googlegroups.com
Dear Jack,

The Builder saves your experiment in a .psyexp file. Every time you make a change and push "Run", Builder then generates a new .py file, which is what PsychoPy actually runs. This is what you see when you push the "Compile script" button, but NB, that step is entirely optional and is only necessary if you want to see what the underlying code is doing or want to jiggle with it. And it is important to realise that this .py file is strictly temporary. It is forever being regenerated by Builder as required. So if you make a change in it and like what it does, you need to save it with a different name, which breaks its link with Builder (which will seamlessly create another one next run).

NB this relationship is strictly one-way: Builder generates .py files, but you can't create or modify a .py file and turn it back into a Builder experiment. Once you have modified the .py output from Builder and saved it as another file, it can then only be run within the Coder environment, as pure Python code. You then have much more flexibility in what you can do, but you lose the ability to graphically lay out your experiment. You're stuck forever in Python code. It's not a bad route though: use Builder to do the leg work of creating the structure of your experiment, and then if you find you hit limits with what it allows you to do, switch to the .py file and just make minor or major tweaks as required.

The goal is that most people should be able to work entirely within the Builder environment. But for some particular experimental requirements or designs, there is complete flexibility awaiting in the Coder view.

Cheers,

Michael


On 30 Mar, 2012, at 11:23, Jack Keegan wrote:

> Hi there,
>
> I've had PsychoPy2 installed for a while but just getting round to using it now. However, when I try to create and experiment using builder and then hit 'compile script' it brings up the code editor. If I make changes here, it doesn't seem to save. I can run the changes from here and they will take effect. However, if I save and close this code editor, I lose all my changes. Is this normal behavior?
>
> Cheers,
>
> Jack

--
Michael R. MacAskill, PhD michael....@nzbri.org
Research Director,
New Zealand Brain Research Institute

66 Stewart St http://www.nzbri.org/macaskill
Christchurch 8011 Ph: +64 3 3786 072
NEW ZEALAND Fax: +64 3 3786 080


Jonathan Peirce

unread,
Mar 30, 2012, 5:20:27 AM3/30/12
to psychop...@googlegroups.com

On 29/03/2012 23:23, Jack Keegan wrote:
> Hi there,
>
> I've had PsychoPy2 installed for a while but just getting round to
> using it now. However, when I try to create and experiment using
> builder and then hit 'compile script' it brings up the code editor. If
> I make changes here, it doesn't seem to save. I can run the changes
> from here and they will take effect. However, if I save and close this
> code editor, I lose all my changes. Is this normal behavior?

I addition to Mike's comments, note that if you make changes and save
your script it's probably a good idea to save it with a different name.
When you compile a builder experiment to script it always uses the same
name as the experiment, and if you've made changes there it will look
like your changes "didn't seem to save".

But if the confusion is that you were expecting the code changes to
propagate back into the builder environment then Mike's right - that's
not possible.

all the best,
Jon

--
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk


This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

Jonathan Peirce

unread,
Aug 7, 2012, 4:05:27 AM8/7/12
to psychop...@googlegroups.com
There is such a thing; a "Code Component".

http://www.psychopy.org/builder/components/code.html

On 07/08/2012 06:36, Paul Kieffaber wrote:
Jon,
I've just started working with PsychoPy this afternoon!  Let me start by saying that it is marvelous!
I ran int the issue in this thread and was wondering why there isn't an option in builder to add a little extra code.  For example, I wanted to set a patch to have a random duration on each trial so I set the Stop (duration) to $random.uniform(1,8) and added "import random" to the top of my script.  Of course, I could no longer make adjustments with the builder.  Couldn't there be a "User defined" button that would open a little text box where a few lines of code could be added?  Then builder would always put this user-defined code at the top of the file?  Eprime has something like this (I forget what it's called) that I use quite frequently.  Not a big deal I know, but would be nice not to have to keep track of all code I plan to add and instead just add code as I build the experiment in builder view.

Thanks for a great program!

Paul
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/K1dQpjFdv_gJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Paul Kieffaber

unread,
Aug 7, 2012, 9:58:48 PM8/7/12
to psychop...@googlegroups.com
Thank you Jon,
I'd been staring right at it all along.

Paul

Jack Keegan

unread,
Aug 10, 2012, 8:24:18 AM8/10/12
to psychop...@googlegroups.com
Hi Guys,

My apologies for not replying sooner. I just seen the replies to this thread now. That definitely clears it up. Thanks very much for your responses.

Cheers,

Jack

To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/CLgf2pR-edwJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Jeremy Gray

unread,
Aug 27, 2012, 3:02:48 PM8/27/12
to psychop...@googlegroups.com
> My question, the modified .py output cannot be opened in Builder anymore,
> from a .py file to a .psyexp file?

Yes, that's correct. It's a one-way street.

Note that you can copy & paste some things within the Builder environment.

--Jeremy

On Mon, Aug 27, 2012 at 2:38 PM, Dana Sugu <sugu...@gmail.com> wrote:
> Hi,
>
> Michael said: " Once you have modified the .py output from Builder and saved
> it as another file, it can then only be run within the Coder environment, as
> pure Python code."
> My question, the modified .py output cannot be opened in Builder anymore,
> from a .py file to a .psyexp file?
>
> Thanks,
> Dana
> --
> You received this message because you are subscribed to the Google Groups
> "psychopy-users" group.
> To post to this group, send email to psychop...@googlegroups.com.
> To unsubscribe from this group, send email to
> psychopy-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/psychopy-users/-/jzBLMNNVZI4J.

Dana Sugu

unread,
Aug 27, 2012, 4:29:34 PM8/27/12
to psychop...@googlegroups.com
Thank you for answering. I can  copy & paste some things within the Builder  but When I paste it does not come in the flaw but in the main window.
I compiled it and it is not in the .py file either. How do I get it in the flaw?


On Tuesday, August 28, 2012 12:08:43 AM UTC+5:30, Dana Sugu wrote:
Hi,

Michael said: " Once you have modified the .py output from Builder and saved it as another file, it can then only be run within the Coder environment, as pure Python code."
My question, the modified .py output cannot be opened in Builder anymore, from a .py file to a .psyexp file?

Thanks,
Dana

On Friday, March 30, 2012 3:53:31 AM UTC+5:30, Jack Keegan wrote:

Jeremy Gray

unread,
Aug 27, 2012, 5:02:13 PM8/27/12
to psychop...@googlegroups.com
after you copy and paste a routine, you then have to click the "Insert
routine" button to add the new routine into the Flow. so "paste" is
not really pasting into the Flow, its only making a copy.
> --
> You received this message because you are subscribed to the Google Groups
> "psychopy-users" group.
> To post to this group, send email to psychop...@googlegroups.com.
> To unsubscribe from this group, send email to
> psychopy-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/psychopy-users/-/76cH5hFBCRsJ.

Dana Sugu

unread,
Aug 27, 2012, 10:58:54 PM8/27/12
to psychop...@googlegroups.com
Thank you. It works great.
Dana
Reply all
Reply to author
Forward
0 new messages