CIXOS-FIA/Sugarizacion/lang-en

From OLPC
< CIXOS-FIA‎ | Sugarizacion
Revision as of 22:34, 14 February 2009 by 201.240.65.125 (talk) (TRADUCIR !!!!!!!!!!!)
Jump to: navigation, search

'''''TRADUCIR !!!!!!!!!!!'''''

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, for 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, 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).

 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')

        # Crea la caja de Herramientas.Que contiene la Barra de Herramientas de la 
        # Actividad, que es la barra que aparece en cada ventana del Azucar y contiene
        # funcionalidades esenciales, como los botones 'Compartir con:' y 'Parar'.
        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        # Crea un nuevo boton con la etiqueta "Hola Mundo".
        self.button = gtk.Button("Hola Mundo")
    
        # Cuando el boton recibe la seNal de "clicked", llamara a la funcion hola()
        # pasando a "None" como argumento. La funcion hola() es definida en
        # lineas mas arriba.
        self.button.connect("clicked", self.hola, None)
    
        # Ajuste el boton para ser nuestro lienzo. El lienzo es la seccion principal 
        # de toda Ventana Azucar. Se llena toda el area debajo 
        # de la caja de herramientas.
        self.set_canvas(self.button)
    
        # El paso final es mostrar esta nueva creacion de widgets.
        self.button.show()
    
        print "AL FINAL DE LA CLASE"

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.)

 File:
 ActividadHolaMundo.py

La estructura del directorio ahora debe verse como:

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

Instale su paquete para el desarrollo

./setup.py dev

(Esto crea un enlace simbólico en ~/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.)