I created an experiment in the PsychoPy builder and it ran smoothly. Then I wanted to clean the code and insert some custom functions (mainly to control the appearance of rating scales in several routines). I occasionally ran the experiment in Code View to insure that it still runs. It did! But when I started it again from Builder View, all my changes were gone. Of course I did save it before I ran the code. I have quite a number of routines so I really would like that the changes that I make in Coder View are applied to my experiment. Can anybody help me out here? Am I getting something wrong about how Builder and Coder interact?
Hi - every time you press the compile button, Psychopy builder creates a .py file file with the same name as the .psyexp file. This will overwrite if there is a .py file with the same name in the same directory.
This is currently a one way street because the builder components are standardised in XML format and are formatted as python code on compilation - going backwards on this introduces too many variables to deal with at this point, so you will have to repeat the changes every time you make a change in builder and then return to coder.
So in short:
If you are using builder, make sure you are really happy with your builder format before moving to coder
Keep backups of your .py files whenever you make drastic changes in builder
Become familiar with the coder view so you can rely less on builder
Hi Fabian,
One more thing - have you considered using Code Components to insert your custom functions? You are limited to frame by frame implementation, but if that isn’t an issue, it could be the way forward.
One more thing - have you considered using Code Components to insert your custom functions? You are limited to frame by frame implementation, but if that isn’t an issue, it could be the way forward.
I had a similar experience. Your problem may very well be different. Mine had to do with the version in which the builder code was originally made. When I upgrade, I keep the old version with a different names somewhere outside of application folderr. To tell the truth I don’t remember whether the trick was going back to the version that the builder program was created, or being sure I was running the latest version. I think running the latest version was the trick, but I don’t remember. It might be making sure that the version that is opened is at least as new as the version the builder was written in. Again, this might be totally wrong.
I have the same problem and I feel like I need to switch between making changes in the builder and the coder… Can you explain what you mean by inserting Code Components? Thanks
@fragmag, Builder has the option to use the Code Component. The code component opens a window, allowing you to enter custom code at different stages of your experiment. For example, at the beginning of your experiment, the beginning of your trial, during your trials on every screen refresh, etc. You can now also select whether you want to use Python or JavaScript coding, and have them compared side by side for easier translation using the code type drop down in the code component window. When you run your experiment, or compile your code, the code from the code components is inserted into your Python or JS scripts which are used to run the experiment.
In the components pane (usually on the right hand side of the Builder window), go to “Custom”, and the first icon (has some algebraic equations on) is the code component. Click the icon, and a code component will be opened and added to your routine.