[Sugar-devel] Python modules (Re: Introducing SimpleActivity / Introduciendo SimpleActivity

Daniel Narvaez dwnarvaez at gmail.com
Fri Nov 22 08:57:00 EST 2013


What npm and pypi gives you in addition to submodules is automatic
dependencies resolving, which is of course overkill if you have a single
module like here but pretty essential if/when we start to get serious with
modularization (if you ever tried to use npm you will know what I mean).


On 22 November 2013 14:37, Agustin Zubiaga Sanchez <aguz at sugarlabs.org>wrote:

> Yes, I was just thinking about that would be great to have a repository
> where to put every "Sugar" python modules, and what thinking about using
> git submodule but it doesn´t makes send for just a .py file, but we could
> use it for bigger libs as I do with sugar-pycha (lib) [1], that every
> activity can use, or the speak engine that Memorize for example uses.
>
> [1] http://git.sugarlabs.org/sugar-pycha
>
> Regards,
> aguz
>
>
> 2013/11/22 Daniel Narvaez <dwnarvaez at gmail.com>
>
>> Nice work, Augustin.
>>
>> I'm going a bit off topic here but in the future I think it would be nice
>> if we had an easy way for activities to pull and update modules like these
>> and include them directly in the bundle, a la nodejs/volojs. It should be
>> easy to build something around distribute/pypi.
>>
>> That makes experimentation much easier because it doesn't force
>> requirements on a new version of the OS, it allows to change the API
>> without breaking the world etc. The disk space waste is negligible and the
>> need of rebuilds to include fixes can be automated away.
>>
>> Really I think the toolkit shipped with the OS should completely go away
>> in the long run. I know this will be controversial, but I thought it was
>> worth to share the tought at least :)
>>
>>
>> On 22 November 2013 02:19, Agustin Zubiaga Sanchez <aguz at sugarlabs.org>wrote:
>>
>>> = English (Español debajo) =
>>>
>>> Hi everyone,
>>>
>>> I am writing to show you what I was developing those last days, in order
>>> to make simpler the developing of Sugar Activities, this module, micro
>>> library or whatever you want to call it, makes much more easier the
>>> processes that every activity does, for example create ToolButtons, add
>>> them to a Toolbar or implement collaboration which is difficult for any
>>> starter developer.
>>> The main idea is include SimpleAcivity in our toolkit, but thinking
>>> about all the review processes it takes, you can add it to your activity
>>> for now or you can take a look about how it works in the Demo activity I
>>> did [1], where you can see how easy is to implement sharing or create the
>>> toolbar.
>>>
>>> * SimpleActivity classes *
>>>
>>> simpleactivity.SimpleActivity:
>>> The activities which doesn't want to implement collaboration, can derive
>>> from this class (instead of sugar3.activity.activity.Activity), this class
>>> automatically adds the toolbar to the activity with his
>>> ActivityToolbarButton and it makes easier some processes related to the
>>> design, e.g. add buttons, separators, or whatever to the toolbar in only
>>> one line and also other things related to the operation for example any
>>> number, string, dictionary or list that is saved into the self.data
>>> variable will be auto kept in the journal, and when the instance runs
>>> again, in self.data will be what you leaved when the activity was closed.
>>> Among these there are many other simple features, that after all, they
>>> do everything much easier.
>>>
>>> simpleactivity.SharedActivity (derives from SimpleActivity, you can use
>>> all its methods): :
>>> From this class should derive every activity which needs to be shared, the
>>> process is greatly simplified cause the communication is done automatically
>>> and the "system" works with something like an event manager, so we only
>>> need to worry about register our events in a python dict, where the keys
>>> are the names of the events and the values are the functions to call when
>>> we receive an event, and when we want to "emit" an event with the values we
>>> need or not, all we have to do is to call send_event(event_name, data)...
>>> And that's all, we don't have to worry about telepathy, dbus or
>>> anything like that, SimpleActivity does everything for you :)
>>> Also it includes an option to send files in a very easy way, using the
>>> method send_file(file_path, data) that notifies every peer that a file is
>>> available, and it can be downloaded just calling the download_file method,
>>> and then SharedActivity will start emiting signals with information related
>>> to the download progress, etc.
>>> The process of downloading is done using another independent tube, then
>>> nothing gets blocked while the file is sent/downloaded, we can continue
>>> sending events while, and everything will continue working.
>>>
>>> Notes:
>>> - Both classes derives from the "natives" classes of sugar, so we can
>>> continue using every method of sugar.activity.activity.Activity or
>>> whatever, without any problem.
>>> - Whole SimpleActivity (module) is only one .py file, then we can put it
>>> into our activity directory easily as we do with HelpButton or
>>> FontComboBox, even if it isn't in sugar toolkit.
>>> - It only supports GTK3, I think it is not necessary to make it
>>> compatible with GTK2, because nowadays the new activities should be did in
>>> GTK3.
>>> - I advice everyone who is interested to take a look of the
>>> documentation that you can found in the docstrings in the file for now (I
>>> will create a cleaner documentation with sphinx), to learn about all you
>>> can do with SimpleActivity.
>>>
>>> Also I started a Feature wiki page [2], but is not ready yet. Could
>>> anyone help me with that?
>>> I need some documentation experts ;)
>>>
>>> I hope you find it useful, as I always say, I love developing for
>>> Sugar, because it causes a great feeling to know that the lines of code I
>>> wrote will be used directly or indirectly by millions of children around
>>> the world.
>>>
>>> [1] https://git.sugarlabs.org/simpleactivity/
>>> [2] http://wiki.sugarlabs.org/go/Features/SimpleActivity
>>>
>>> Thank you very much,
>>> aguz
>>>
>>> -
>>> = Español =
>>>
>>> Hola a todos,
>>>
>>> Les escribo para presentarles lo que he estado desarrollando estos
>>> últimos días, con el fin de hacer más simple la creación de actividades
>>> para Sugar, este modulo, micro librería, o como quieran llamarle, hace
>>> mucho más fácil los procesos que todas las actividades hacen, como crear
>>> ToolButtons, agregarlos a una Toolbar o implementar colaboración para
>>> cualquier desarrollador que esté comenzando.
>>> La idea principal es incluir SimpleActivity en la toolkit de sugar, pero
>>> tomando en cuenta todos los procesos de revisados que lleva, pueden ver
>>> como funciona en el repositorio de la actividad de ejemplo
>>> HelloSimpleActivity [1], que implementa un montón de características, y
>>> donde pueden ver lo fácil que es implementar la colaboración o hacer la
>>> barra de herramientas.
>>>
>>> * Clases de simpleactivity *
>>>
>>> simpleactivity.SimpleActivity:
>>> Las actividades que NO deseen implementar colaboración, pueden
>>> simplemente heredar de esta clase (en lugar de
>>> sugar3.activity.activity.Activity), esta clase agrega automáticamente la
>>> toolbar a la actividad con su ActivityToolButton, y simplifica varios
>>> procesos relacionados con el diseño por ejemplo agregar botones,
>>> separadores (o lo que sea) a la toolbar en una sola linea y también otros
>>> de funcionamiento como por ejemplo cualquier numero, string, diccionario o
>>> lista que se guarde, en la variable self.data, al cerrar la actividad esta
>>> lo guardará automáticamente en el journal y al abrir otra vez esta
>>> instancia de nuestra actividad, en self.data estará lo que allí dejamos.
>>> Entre estas hay muchas otras características simples, que al fin y al
>>> cabo, hacen todo mucho más fácil.
>>>
>>> simpleactivity.SharedActivity (hereda de SimpleActivity, puedes usar
>>> támbien todos sus metodos):
>>> De esta clase deben heredar todas las actividades que deseen implementar
>>> colaboración, el proceso se simplifica enormemente, ya que la comunicación
>>> la hace toda automática, el "sistema" funciona con una especie de manejador
>>> de eventos, por lo que solo debemos de preocuparnos por registrar nuestros
>>> eventos en un diccionario de python, donde las claves son los nombres de
>>> los eventos y los valores son las funciones a llamar cuando alguien nos
>>> envie ese evento, y cuando deseamos emitirlos con los valores que
>>> necesitemos o no (simpleactivity se encargara de notificar a cada maquina y
>>> enviar a todos los datos) simplemente llamamos a una función
>>> send_event(nombre_evento, datos)... Y listo! No debemos preocuparnos por
>>> telepathy, dbus ni nada por el estilo, SimpleActivity hace todo por ti :)
>>> Además incluye la opción de enviar archivos de una manera muy fácil,
>>> utilizando un metodo send_file que avisa a todas las demás maquinas, que
>>> hay un archivo disponible y podemos acceder a descargarlo simplemente
>>> llamando la función download_file y SharedActivity comenzará a emitir
>>> señales con información acerca del progreso de descarga, etc.
>>> El proceso de descarga de archivos se hace por un tubo aparte por lo
>>> cual, nada se bloquea mientras el archivo se envia/descarga, podemos seguir
>>> enviando eventos sin problemas mientras lo hacemos, y todo seguirá
>>> funcionando.
>>>
>>> Notas:
>>> - Ambas clases heredan de las clases nativas de sugar, por lo cual
>>> podemos utilizar todos los métodos de  sugar3.activity.activity.Activity o
>>> lo que sea que deseemos, sin ningún problema.
>>> - SimpleActivity (módulo) es en su totalidad un solo archivo .py por lo
>>> que podemos incorporarlo en nuestra actividad muy fácilmente, así como lo
>>> hacemos con HelpButton o FontComboBox, aunque aún no esten en sugar toolkit.
>>> - Soporta solo GTK3, creo que no es necesario dedicarnos a hacer una
>>> versión compatible con GTK2, porque hoy en día las actividades nuevas se
>>> deben hacer desde el inicio con GTK3.
>>> - Recomiendo a todos los interesados revisar la documentación que está
>>> en docstrings en el archivo por ahora, (proximamente armaré una
>>> documentación más prolija con sphinx), para enterarse de todo lo que se
>>> puede hacer con simpleactivity.
>>>
>>> Además comencé con una pagina en la wiki [2], pero todavía no está
>>> lista. ¿Alguien quiere ayudarme con eso?
>>> Necesito ayuda de los expertos en documentación ;)
>>>
>>> Espero que les sea útil, como siempre digo, me encanta desarrollar para
>>> Sugar, porque me provoca un sentimiento inexplicable saber que las lineas
>>> de código que escribo van a ser utilizadas directa o indirectamente por
>>> millones de chicos al rededor del mundo.
>>>
>>> [1] https://git.sugarlabs.org/simpleactivity/
>>> [2] http://wiki.sugarlabs.org/go/Features/SimpleActivity
>>>
>>> Muchas gracias,
>>> aguz
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Sugar-devel mailing list
>>> Sugar-devel at lists.sugarlabs.org
>>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>>
>>>
>>
>>
>> --
>> Daniel Narvaez
>>
>> _______________________________________________
>> Sugar-devel mailing list
>> Sugar-devel at lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>
>>
>


-- 
Daniel Narvaez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20131122/b38eb903/attachment.html>


More information about the Sugar-devel mailing list