Changes

Jump to navigation Jump to search
m
no edit summary
Line 1: Line 1: −
<noinclude>{{GoogleTrans-en}}{{TOCright}}</noinclude>
+
<noinclude></noinclude>
 
==Editing==
 
==Editing==
This describes how to reprogram activities using Sugar and the activities Browse, Pippy & Terminal. It does not require any extra development tools. Development is done directly on the OLPC XO, alternatively it can be done using the [[Live CD]], [[Sugar on a Stick]] or other implementations of Sugar.  
+
This describes how to reprogram activities using just the tools that come with the Sugar operating system. It does not require any extra development tools. Development is done directly on the OLPC XO, alternatively it can be done using the [[Live CD]], [[Sugar on a Stick]] or other implementations of Sugar.  
   −
This page is targeted at beginners, more experienced users may find reading [[Activities/Turtle Art/Patching]] , [[Activity_Team/Resources]] and [[Activity_Team/Creating_a_New_Activity]] useful.
+
This page is targeted at beginners, more experienced users may find reading [[Activities/Turtle Art/Patching]] , [[Activity Team/Resources]] and [[Activity Team/Creating a New Activity]] useful.
   −
The activities are  stored  at ''/home/olpc/Activities'' and you can use the browser as a "file manager" to browse the file system using the URL prefix ''file://''
+
The activities are  stored  at ''/home/olpc/Activities'' and you can use Browse as a "file manager" to browse the file system using the URL prefix ''file://''
   −
For example, type ''file:///home/olpc/Activities/TurtleArt.activity'' into the browser address bar to see the Python files that make up the TurtleArt activity. Click on one of the *.py files to inspect the code.
+
For example, type ''file:///home/olpc/Activities/TurtleArt.activity'' into the browser address bar to see the Python files that make up the Turtle Art activity. Click on one of the *.py files to inspect the code.
   −
You can view the code but not edit it in the browser. To edit, select the code and copy to the clipboard (ctrl c) and open Pippy (the Python editor) and paste it to the code window (ctrl v). You can then edit the code and save it to the Journal, ''keep as Pippy document'' and using a suitable filename (eg ''filename.py'')
+
You can view the code but not edit it in Browse.
 +
 
 +
There are the following options for file editing
 +
===The vi editor===
 +
In terminal type
 +
  vi ''filename''
 +
The syntax of vi is obscure for the unfamiliar.
 +
 
 +
* an alternate to vi is to install GEdit, to download and install Gedit type
 +
su yum install gedit
 +
in sugar terminal (satellit 06/09/2010)
 +
 
 +
===The GNOME desktop on dual desktop laptops===
 +
Double click on "Computer" to navigate, double clicking a file will open it in GEdit.
 +
 
 +
===Using GEdit from Terminal===
 +
GEdit will be found on dual desktop systems, notably the [http://people.sugarlabs.org/bernie/olpc/f11-xo1-0.88/ Paraguay builds].
 +
If used as above, it does not allow editing in directories above /home/olpc.
 +
To access the higher level directories run GEdit from Terminal in either Sugar or GNOME and use the su or sudo commands. (If editing OLPC system level files, it is wise to have backed up important work and know how to [http://wiki.laptop.org/go/Clean-install_procedure reflash the operating system]).
 +
  su
 +
  gedit
 +
or
 +
  sudo gedit
 +
 
 +
===Using Pippy or Write===
 +
 
 +
To edit, select the code in Browse and copy to the clipboard (ctrl c) and open Pippy (the Python editor) and paste it to the code window (ctrl v). You can then edit the code and save it to the Journal, ''keep as Pippy document'' and using a suitable filename (eg ''filename.py'')
    
To run the modified code, you need to copy it from the journal back to the directory that the activity resides in, in this case  ''/home/olpc/Activities/TurtleArt.activity''
 
To run the modified code, you need to copy it from the journal back to the directory that the activity resides in, in this case  ''/home/olpc/Activities/TurtleArt.activity''
Line 25: Line 51:  
     mv filename..py filename.py
 
     mv filename..py filename.py
    +
===Develop Activity===
 
There is an activity [http://wiki.laptop.org/go/Develop Develop] which has a file manager and an editor, currently (at writing this) version 35 seems to be buggy. It shares the limitation with the above method that it saves to the journal, not the activity's directory. If working OK, its only benefit may be avoiding the step of copying from Browse to Pippy
 
There is an activity [http://wiki.laptop.org/go/Develop Develop] which has a file manager and an editor, currently (at writing this) version 35 seems to be buggy. It shares the limitation with the above method that it saves to the journal, not the activity's directory. If working OK, its only benefit may be avoiding the step of copying from Browse to Pippy
   −
==Modifying TurtleArt Files==
+
==Turtle in a pond==
(see also [[Activities/TurtleArt-0.88#Programmable_Brick]])
+
[[Activities/Turtle in a Pond]] is an Activity designed to be modified. Keep the Turtle in the pond. Write your own short Python program.
 +
 
 +
==Modifying Turtle Art Files==
 +
(see also [[Activities/Turtle Art-0.88#Programmable_Brick]])
    
Turtle Art has a special block that is programmable in Pippy. Look for the tamyblock.py entry in your Journal. Try uncommenting one of the examples.
 
Turtle Art has a special block that is programmable in Pippy. Look for the tamyblock.py entry in your Journal. Try uncommenting one of the examples.
Line 68: Line 98:     
===turtleart.py===
 
===turtleart.py===
This file is not used by Sugar to launch TurtleArt but you can use it to launch TurtleArt from the terminal, go to ''/home/olpc/Activities/TurtleArt.activity'' and type
+
This file is not used by Sugar to launch Turtle Art but you can use it to launch Turtle Art from the terminal, go to ''/home/olpc/Activities/TurtleArt.activity'' and type
    
  python turtleart.py
 
  python turtleart.py
Line 80: Line 110:  
  twNew(win1, os.path.abspath('.'),'en')
 
  twNew(win1, os.path.abspath('.'),'en')
   −
===taturtle.py===
+
===tacanvas.py===
 
This file handles the turtle drawing functions, for example the following code calculates which of the 36 turtle sprites, each rotated by 10 degrees to draw, depending on the heading.
 
This file handles the turtle drawing functions, for example the following code calculates which of the 36 turtle sprites, each rotated by 10 degrees to draw, depending on the heading.
   Line 95: Line 125:  
[[Image:Bad_heading.jpg]]<br>
 
[[Image:Bad_heading.jpg]]<br>
   −
===tasetup.py===
+
===Localizing Turtle Art===
This file controls, amongst other things the docking behaviour of the blocks. The arithmetic operators +-*/ have equal block dimensions and dock both sides with number blocks. They are defined as having an ''ari'' docking style.
  −
 
  −
    ('plus','+','ari'),
  −
    ('minus','-','ari'),
  −
    ('product','*','ari'),
  −
    ('division','/','ari'),
  −
 
  −
And the docking points, left and right, are given coordinates in the following code
  −
 
  −
  'ari':    (('numend',True,12,20),('num',False,39,20)),
  −
 
  −
The effect of changing the y coordinates of the left and right docking points from 20 to 10 and 30 are shown below.<br>
  −
 
  −
  'ari':    (('numend',True,12,10),('num',False,39,30)),
  −
 
  −
[[Image:Bad_ari_dock.jpg]]<br>
  −
 
  −
===Localizing TurtleArt===
   
The best way to contribute to translations for Sugar Activities is through http://translate.sugarlabs.org/ In the next release cycle, your translations will be available to millions of users.
 
The best way to contribute to translations for Sugar Activities is through http://translate.sugarlabs.org/ In the next release cycle, your translations will be available to millions of users.
   −
Here follows a quick and dirty hack to add translations to a local copy of TurtleArt.  
+
Here follows a quick and dirty hack to add translations to a local copy of Turtle Art.  
   −
For TurtleArt, the translations' source resides at /home/olpc/Activities/TurtleArt.activity/po For example, the Slovenian translation source is in sl.po. The file consists of untranslated and translated string pairs:
+
For Turtle Art, the translations' source resides at /home/olpc/Activities/TurtleArt.activity/po For example, the Slovenian translation source is in sl.po. The file consists of untranslated and translated string pairs:
    
  msgid "untranslatedstring"
 
  msgid "untranslatedstring"
Line 128: Line 140:  
* on dual boot laptops use the GNOME desktop
 
* on dual boot laptops use the GNOME desktop
   −
Compile the po file to a mo file using msgfmt http://linuxcommand.org/man_pages/msgfmt1.html
+
Compile the po file to a mo file using the command [http://linuxcommand.org/man_pages/msgfmt1.html msgfmt] in terminal.
    
Put the compiled mo file in the right directory and with the right file name, eg for Slovenian that is /home/olpc/Activities/TurtleArt.activity/locale/sl/LC_MESSAGES/org.laptop.TurtleArtActivity.mo
 
Put the compiled mo file in the right directory and with the right file name, eg for Slovenian that is /home/olpc/Activities/TurtleArt.activity/locale/sl/LC_MESSAGES/org.laptop.TurtleArtActivity.mo

Navigation menu