CIXOS-FIA/Sugarizacion: Difference between revisions

From OLPC
Jump to navigation Jump to search
(New page: El tutorial explica paso a paso como crear el [http://divieira.googlepages.com/HelloWorld-1.xo Paquete de la actividad Hola Mundo]. Se asume que ya ha [[:Category:Installing Sugar|instala...)
 
No edit summary
Line 1: Line 1:
El tutorial explica paso a paso como crear el [http://divieira.googlepages.com/HelloWorld-1.xo Paquete de la actividad Hola Mundo].
The tutorial explain with detail as create the [http://divieira.googlepages.com/HelloWorld-1.xo Paquete de la actividad Hola Mundo].


Se asume que ya ha [[:Category:Installing Sugar|instalado el entorno de desarrollo Azúcar]].
To assume that you have [[:Category:Installing Sugar|instalado el entorno de desarrollo Azúcar]].


Create the structure of directorys of the package:
Crear la estructura de directorios del paquete:


mkdir HolaMundo.activity
mkdir HolaMundo.activity
mkdir HolaMundo.activity/activity
mkdir HolaMundo.activity/activity


Escribir el archivo activity.info, para describir el paquete en el sub-directorio de la actividad (por ejemplo, HolaMundo.activity/activity/activity.info). Las especificaciones de los [[Activity Bundles|Paquetes de Actividad]] explican en detalle el significado de cada campo.
Write the archive activity.info, to describe the package in the sub-directory of the activity (for example, HolaMundo.activity/activity/activity.info).The instructions of the [[Activity Bundles|Paquetes de Actividad]] explain in detail the mean of each sphere.


{{ Box File | activity.info | 2=<pre>
{{ Box File | activity.info | 2=<pre>
Line 21: Line 21:
}}
}}


Diseñe un icono para su actividad, de acuerdo con el [[Sugar_Icon_Format|formato del icono]] y colóquelo en el sub-directorio "activity". El nombre del archivo debe coincidir con el nombre especificado en el archivo .info (por ejemplo, actividad-holamundo.svg)
Design an icon for you activity,in accordance with the [[Sugar_Icon_Format|formato del icono]] and you put in the sub-directory "activity".The name of archive must coincide with the name written in the archive .info (for example, actividad-holamundo.svg)


{{ Box File | actividad-holamundo.svg | 2=<pre>
{{ Box File | actividad-holamundo.svg | 2=<pre>
Line 34: Line 34:
</pre>
</pre>
}}
}}
Write the script setup.py in the directory of higher level (for example, HolaMundo.activity/setup.py), that in the majority of the cases will see like this:

Escribir el script setup.py en el directorio de nivel superior (por ejemplo, HolaMundo.activity/setup.py), que en la mayoría de los casos se verá asi:


{{ Box File | setup.py | 2=<pre>
{{ Box File | setup.py | 2=<pre>
Line 44: Line 43:
}}
}}


Codifique su actividad. El nombre que ha especificado en el archivo .info como "class" es el nombre de la clase que ejecuta el código. Para el archivo anterior activity.info, especificamos un modulo de alto nivel ActividadHolaMundo.ActividadHolaMundo (por favor, tenga en cuenta que el uso de mayúsculas en los nombres de módulos en Python es un estilo pobre, siéntase libre de utilizar el nombre de una actividad con mas estilo de nombres estándar).
Check your activity.The name that you have written in the archive .info as "class" is the name of the class that make the code. To the archive previous activity.info, we especificed a module of high level ActividadHolaMundo.ActividadHolaMundo (please, remember the use of capital letters in the names of modules in Python is a poor style , you are free of use the name of an activity with more style of standard names).


{{ Box File | ActividadHolaMundo.py | 2=<pre>
{{ Box File | ActividadHolaMundo.py | 2=<pre>
Line 64: Line 63:
self.set_title('Hola Mundo')
self.set_title('Hola Mundo')


# Crea la caja de Herramientas.Que contiene la Barra de Herramientas de la
# Create the toolbox .That contain the toolbar of the
# Actividad, que es la barra que aparece en cada ventana del Azucar y contiene
# Activity,that is the bar appear in each window of the sugar and contain
# funcionalidades esenciales, como los botones 'Compartir con:' y 'Parar'.
# essentials functions, as the buttons 'Compartir con:' and 'Parar'.
toolbox = activity.ActivityToolbox(self)
toolbox = activity.ActivityToolbox(self)
self.set_toolbox(toolbox)
self.set_toolbox(toolbox)
toolbox.show()
toolbox.show()


# Crea un nuevo boton con la etiqueta "Hola Mundo".
# Create a new button with the name "Hola Mundo".
self.button = gtk.Button("Hola Mundo")
self.button = gtk.Button("Hola Mundo")
# Cuando el boton recibe la seNal de "clicked", llamara a la funcion hola()
# When the button receive the sign of "clicked", will call the function hello()
# pasando a "None" como argumento. La funcion hola() es definida en
# passing to "None" as argument.The function hello() is defined in
# lineas mas arriba.
# lines more above.
self.button.connect("clicked", self.hola, None)
self.button.connect("clicked", self.hola, None)
# Ajuste el boton para ser nuestro lienzo. El lienzo es la seccion principal
# Fix the button to be our linen. The linen is the main section
# de toda Ventana Azucar. Se llena toda el area debajo
# of every sugar window. Cover all the area under
# de la caja de herramientas.
# the toolbox.
self.set_canvas(self.button)
self.set_canvas(self.button)
# El paso final es mostrar esta nueva creacion de widgets.
#Finally you must show this new creation of widgets.
self.button.show()
self.button.show()
Line 91: Line 90:
}}
}}


Crear un MANIFEST (por ejemplo, HolaMundo.activity/MANIFEST), que contiene la lista de los archivos a incluir en el paquete. (Nota: Asegúrese de '''no''' dejar líneas en blanco al final del archivo.)
Create a MANIFEST (for example, HolaMundo.activity/MANIFEST),that contain the list of the archives include in the package . (Note: Make sure of '''not''' leave lines in white in the final of the archive.)


{{ Box File | | 2=<pre>
{{ Box File | | 2=<pre>
Line 98: Line 97:
}}
}}


The structure of the directory now must see as:
La estructura del directorio ahora debe verse como:
HolaMundo.activity/
HolaMundo.activity/
HolaMundo.activity/setup.py
HolaMundo.activity/setup.py
Line 107: Line 106:
HolaMundo.activity/MANIFEST
HolaMundo.activity/MANIFEST


Install your package to the develop
Instale su paquete para el desarrollo
./setup.py dev
./setup.py dev


(Esto crea un enlace simbólico en ~/Activities).
(This create a symbolic link in ~/Activities).


Si ahora ejecuta el Azúcar, el icono de la actividad debe ser visible en el marco. (Hay que reiniciar el Azúcar para ver el cambio. Pulsa Ctrl-Alt-borrar.)
If now perform the sugar, the icon of the activity must be visible in the frame. (Reboot the sugar to see the change . Press Ctrl-Alt-delete.)


[[category:groups]]
[[category:groups]]

Revision as of 16:22, 20 February 2009

The tutorial explain with detail as create the Paquete de la actividad Hola Mundo.

To assume that you have instalado el entorno de desarrollo Azúcar.

Create the structure of directorys of the package:

mkdir HolaMundo.activity
mkdir HolaMundo.activity/activity

Write the archive activity.info, to describe the package in the sub-directory of the activity (for example, HolaMundo.activity/activity/activity.info).The instructions of the Paquetes de Actividad explain in detail the mean of each sphere.

 File: activity.info
 [Activity]
 name = HolaMundo
 service_name = com.ywwg.HelloWorldActivity
 class = ActividadHolaMundo.ActividadHolaMundo
 icon = actividad-holamundo
 activity_version = 1
 show_launcher = yes

Design an icon for you activity,in accordance with the formato del icono and you put in the sub-directory "activity".The name of archive must coincide with the name written in the archive .info (for example, actividad-holamundo.svg)

 File: actividad-holamundo.svg
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
        <!ENTITY fill_color "#FFFFFF">
        <!ENTITY stroke_color "#FF0000">
]>
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
<rect x="1" y="1" width="48" height="48" style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:2"/>
</svg>

Write the script setup.py in the directory of higher level (for example, HolaMundo.activity/setup.py), that in the majority of the cases will see like this:

 File: setup.py
 #!/usr/bin/python
 from sugar.activity import bundlebuilder
 bundlebuilder.start()

Check your activity.The name that you have written in the archive .info as "class" is the name of the class that make the code. To the archive previous activity.info, we especificed a module of high level ActividadHolaMundo.ActividadHolaMundo (please, remember the use of capital letters in the names of modules in Python is a poor style , you are free of use the name of an activity with more style of standard names).

 File: ActividadHolaMundo.py
from sugar.activity import activity
import logging

import sys, os
import gtk

class ActividadHolaMundo(activity.Activity):
    def hola(self, widget, data=None):
        logging.info('Hola Mundo')

    def __init__(self, handle):
        print "ejecutando actividad init", handle
        activity.Activity.__init__(self, handle)
        print "ejecutando actividad"

        self.set_title('Hola Mundo')

        # Create the toolbox .That contain the toolbar of the  
        # Activity,that is the bar appear in each window of the sugar and contain
        # essentials functions, as the buttons  'Compartir con:' and 'Parar'.
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        # Create a new button with the name "Hola Mundo".
        self.button = gtk.Button("Hola Mundo")
    
        # When the button receive the sign of "clicked", will call the function hello()
        # passing to "None" as argument.The function hello() is defined in 
        # lines more above.
        self.button.connect("clicked", self.hola, None)
    
        # Fix the button to be our linen. The linen is the main section  
        # of every sugar window. Cover all the area under  
        # the toolbox.
        self.set_canvas(self.button)
    
        #Finally you must show this new creation of widgets.
        self.button.show()
    
        print "AL FINAL DE LA CLASE"

Create a MANIFEST (for example, HolaMundo.activity/MANIFEST),that contain the list of the archives include in the package . (Note: Make sure of not leave lines in white in the final of the archive.)

 File:
 ActividadHolaMundo.py

The structure of the directory now must see as:

HolaMundo.activity/
HolaMundo.activity/setup.py
HolaMundo.activity/activity
HolaMundo.activity/activity/activity.info
HolaMundo.activity/activity/actividad-holamundo.svg
HolaMundo.activity/ActividadHolaMundo.py
HolaMundo.activity/MANIFEST

Install your package to the develop

./setup.py dev

(This create a symbolic link in ~/Activities).

If now perform the sugar, the icon of the activity must be visible in the frame. (Reboot the sugar to see the change . Press Ctrl-Alt-delete.)