Using Python blocks in TurtleArt
The Python block and file tamyblock.py
There is the facility to insert a block of Python code into TurtleArt in its current experimental fork, TurtleArtPortfolio on the OLPC. (This feature is now in Turtle Art from V44) Thanks Walter for the following help.
As of TurtleArtPortfolio V17 , when TA is first run, it creates a copy of tamyblock.py in the journal.
This code can be opened with Pippy and edited. There are some example blocks of code there which are commented out with #
The Python code can be loaded into TA using the Save/Load menu tab.
Replacing a deleted tamyblock.py
If you delete tamyblock.py from the journal, you need to manually replace it (this may change with later versions). In terminal go to directory
//home/olpc/Activities/TurtleArtPortfolio.activity
and use the copy-to-journal command, note you need to supply the MIME (see also) type for the file, text/x-python:
Errors executing the code and the output of any print statements are directed to the (TAPortfolioActivity ??) log file The log files are at ~/.sugar/default/logs and can be viewed with the Log activity
Rainbow security
Currently having problems with Rainbow security settings, follow this link to Rainbow for how to disable it.
Version 19 update
Rainbow problem circumvented V19. tamyblock not required, cannot do imports
There is the facility to insert a block of Python code into TurtleArt in its current experimental fork, TurtleArtPortfolio on the OLPC. (This feature is now in Turtle Art from V44) Thanks Walter for the following help.
As of TurtleArtPortfolio V17 , when TA is first run, it creates a copy of tamyblock.py in the journal.
This code can be opened with Pippy and edited. There are some example blocks of code there which are commented out with #
The Python code can be loaded into TA using the Save/Load menu tab.
Replacing a deleted tamyblock.py
If you delete tamyblock.py from the journal, you need to manually replace it (this may change with later versions). In terminal go to directory
//home/olpc/Activities/TurtleArtPortfolio.activity
and use the copy-to-journal command, note you need to supply the MIME (see also) type for the file, text/x-python:
copy-to-journal tamyblock.py -m text/x-pythonError messages
Errors executing the code and the output of any print statements are directed to the (TAPortfolioActivity ??) log file The log files are at ~/.sugar/default/logs and can be viewed with the Log activity
Rainbow security
Currently having problems with Rainbow security settings, follow this link to Rainbow for how to disable it.
Version 19 update
Rainbow problem circumvented V19. tamyblock not required, cannot do imports
4 Comments:
Is there a published bug report that you'd like me to examine for the rainbow-related issue you mention?
Hi, Michael, not sure I know how to file a bug. The following error happens when importing tamyblock.py from the Journal. I am told that you do not get this error if Rainbow is disabled
1236126297.789596 WARNING root: Invocation of ObjectChooser() has deprecated parameters.
1236126300.178693 WARNING root: Invocation of ObjectChooser() has deprecated parameters.
cp: cannot create regular file `/home/olpc/isolation/1/uid_to_home_dir/10008/data/tamyblock.py': Permission denied
chmod: changing permissions of `/home/olpc/isolation/1/uid_to_home_dir/10008/data/tamyblock.py': Operation not permitted
cp: cannot create regular file `/home/olpc/isolation/1/uid_to_home_dir/10008/data/tamyblock.py': Permission denied
chmod: changing permissions of `/home/olpc/isolation/1/uid_to_home_dir/10008/data/tamyblock.py': Operation not permitted
Oh, that's an easy one, Tony: activities can't write to their own directories. In the future, activities might be executed in-place from compressed .zip bundles; obviously you can't write to the middle of those.
Just put your tamyblock.py someplace writeable by your activity, either /tmp or the persistent activity directory. (Michael, did you ever make $HOME point to a writeable place for activities?)
Thanks Scott
I have passed this on to Walter, he understands this stuff.
Post a Comment
<< Home