From 347a984231a15c5bff7e42652686f1c42cd13b7a Mon Sep 17 00:00:00 2001 From: Rodrigo Perez Date: Wed, 20 Mar 2013 14:00:24 +0000 Subject: First commit --- diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..0855d41 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,194 @@ +setup.py + + +TInterpreter.py +TInterpreterBoard.py +TInterpreterProject.py + + +activity/activity.info +components/TInterpreterAcumulatedCell.py +components/TInterpreterCell.py +components/TInterpreterCommonCell.py +components/TInterpreterCommonControl.py +components/TInterpreterConstants.py +components/TInterpreterControlCell.py +components/TInterpreterTextArea.py +components/__init__.py +components/rules/__init__.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +speak/espeak_cmd.py + + + +speak/voice.py +speak/__init__.py +threads/TInterpreterPlaySound.py +threads/__init__.py +util/ControlFactory.py + +util/OpenNewProject.py + +util/__init__.py + + + + + + + +util/ChooseProject.py +po/TicoTico.pot + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +icons/open.svg +util/About.py +activity/Activity-TicoTico.svg + + + + + + +proyectos/.empty +generar.sh +util/Singleton.py + +icons/barrido.svg +proyectos/Muestra/project.xml +proyectos/Muestra/image/2314.png +proyectos/Muestra/image/2304_1.png +proyectos/Muestra/image/2374.png +proyectos/Muestra/image/2586.png +proyectos/Muestra/image/6632_1.png +proyectos/Muestra/image/2487.png +proyectos/Muestra/image/24795.png +proyectos/Muestra/image/2430.png +proyectos/Muestra/image/controller-home.png +proyectos/Muestra/image/2401.png +proyectos/Muestra/image/2300.png +proyectos/Muestra/image/2245.png +proyectos/Muestra/image/4962.png +proyectos/Muestra/image/2349.png +proyectos/Muestra/image/6522.png +proyectos/Muestra/image/2606.png +proyectos/Muestra/image/2587.png +proyectos/Muestra/image/5957_1.png +proyectos/Muestra/image/2370.png +proyectos/Muestra/image/25191.png +proyectos/Muestra/image/2684.png +proyectos/Muestra/image/5441.png +proyectos/Muestra/image/3250.png +proyectos/Muestra/image/6625_1.png +proyectos/Muestra/image/teleton.png +proyectos/Muestra/image/2367.png +proyectos/Muestra/image/6537.png +proyectos/Muestra/image/8662.png +proyectos/Muestra/image/7061.png +proyectos/Muestra/image/controller-home_1.png +proyectos/Muestra/image/24735.png +speak/GoogleTTS.py +speak/new_main.py + + + + + + + + + + + + + + + + + +Tixo.py + +po/TIXO.pot diff --git a/Readme.txt b/Readme.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Readme.txt diff --git a/TInterpreter.py b/TInterpreter.py new file mode 100644 index 0000000..aef5706 --- /dev/null +++ b/TInterpreter.py @@ -0,0 +1,113 @@ +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +__author__ = "Rodrigo" +__date__ = "$20-sep-2012 12:16:32$" + +from TInterpreterProject import TInterpreterProject +from util.OpenNewProject import OpenNewProject +from util.ChooseProject import ChooseProject +import pygtk +pygtk.require('2.0') +import gtk +import os +import sys + +class TInterpreter: + PROYECTOS = "proyectos" + + def __init__(self): + self.project = TInterpreterProject() + + def load(self, xml): + self.project.XMLDecode(xml) + self.project.setCurrentBoard(self.project.getInitialBoard()) + self.project.show_all() + + + def getContenedor(self): + return self.project + + def exit(self, widget, data=None): + gtk.main_quit() + sys.exit + + def barrido(self, otro=None): + self.project.barrido() + + def cambiarVelocidad(self, value): + self.project.cambiarVelocidad(value) + + + +#PARA EL FUNCIONAMIENTO FUERA DE SUGAR + def mainPropio(self): + #self.project.XMLDecode("proyectos/Muestra/project.xml") + #self.project.setCurrentBoard(self.project.getInitialBoard()) + + self.win = gtk.Window() + w = self.win + w.connect("destroy", self.exit) + + self.container = gtk.VBox(); + + self.toolbar = gtk.Toolbar() + self.toolbar.append_item("Agregar", "Agregar Proyecto", None, None, self.__agregar) + self.toolbar.append_item("Abrir", "Abrir Proyecto", None, None, self.__abrir) + self.toolbar.append_item("Barrido", "Barrido Automatico", None, None, self.barrido) + self.toolbar.show() + self.container.pack_start(self.toolbar) + + self.container.pack_start(self.project) + + w.add(self.container) + + w.show_all() + + + gtk.main() + + def __agregar(self, widget): + dialog = gtk.FileChooserDialog(title="Abrir", action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + response = dialog.run() + if response == gtk.RESPONSE_OK: + try: + onp = OpenNewProject(dialog.get_filename(), os.path.basename(dialog.get_filename())) + self.load(os.path.join(self.PROYECTOS, onp.getProjectName(), "project.xml"),) + except Exception, e: + print "Exception: ", e + elif response == gtk.RESPONSE_CANCEL: + print 'Closed, no files selected' + + dialog.destroy() + + def __abrir(self, widget): + abr = ChooseProject(self.PROYECTOS) + abr.addOnAbrirListener(self.__abierto) + abr.show() + + def __abierto(self, proyName): + self.load(os.path.join(self.PROYECTOS, proyName, "project.xml"),) + + + +if __name__ == "__main__": + b = TInterpreter() + b.mainPropio() diff --git a/TInterpreterBoard.py b/TInterpreterBoard.py new file mode 100644 index 0000000..876f898 --- /dev/null +++ b/TInterpreterBoard.py @@ -0,0 +1,131 @@ +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +__author__ = "Rodrigo" +__date__ = "$20-sep-2012 10:15:25$" + +from threading import Thread +import gobject +gobject.threads_init() +import time +import pygtk +pygtk.require('2.0') +import gtk + + +class TInterpreterBoard(gtk.EventBox): + def __init__(self): + self.cellList = {} + super(TInterpreterBoard, self).__init__() + self.f = gtk.Fixed() + self.add(self.f) + + self.cellResaltada = None + + self._backgroundColor = None + self.barriendo = False + self.velocidadBarrido = 2.0 + + +#========SETUP FUNCTIONS======================================================== + def setNombre(self, value): + self._nombre = value + + def setOrderedCellList(self, list): + self._orderedCellList = list + + def setOriginalSize(self, value): + self._originalSize = value + + def addCell(self, cell): + self.cellList[cell.getId()] = cell + + def setBackgroundColor(self, color): + self._backgroundColor = color + + +#======GET FUNCTIONS============================================================ + def getNombre(self): + return self._nombre + +#======INITIALIZATION + + def initialize(self): + if self._backgroundColor: + color = self.get_colormap().alloc_color("#" + self._backgroundColor.upper()[2:]) + + self.modify_bg(gtk.STATE_NORMAL, color) + self.modify_bg(gtk.STATE_PRELIGHT, color) + + for cell in self.cellList.itervalues(): + cell.initialize() + cell.set_size_request(cell.getWidth(), cell.getHeight()) + self.f.put(cell, cell.getX(), cell.getY()) + + self.show_all() + + +#======BARRIDO AUTOMATICO======================================================= + def barrer(self): + while self.barriendo: + if self.cellResaltada != None: + gobject.idle_add(self.cellList[self.cellResaltada].desResaltar) + + self.cellResaltada = self._orderedCellList[self.barridoActual] + gobject.idle_add(self.cellList[self.cellResaltada].resaltar) + + if self.barridoActual < len(self._orderedCellList) - 1: + self.barridoActual += 1 + else: + self.barridoActual = 0 + + time.sleep(self.velocidadBarrido) + + def accionarSeleccionado(self, widget, data): + self.cellList[self.cellResaltada].onClick(None) + + + + + def iniciarBarrido(self): + self.barriendo = True + # And bind an action to it + #self.set_events(gtk.gdk.BUTTON_PRESS_MASK) + self._handl_id = self.connect("button_press_event", self.accionarSeleccionado) + self.barridoActual = 0 + #self.t = Timer(2.0, self.barrerSiguiente) + self.t = Thread(target= self.barrer) + + self.t.start() + + def detenerBarrido(self): + self.barriendo = False + self.disconnect(self._handl_id) + + def setVelocidadBarrido(self, value): + self.velocidadBarrido = value + + def getVelocidadBarrido(): + return self.velocidadBarrido + + +if __name__ == "__main__": + print "Hello World" diff --git a/TInterpreterProject.py b/TInterpreterProject.py new file mode 100644 index 0000000..2975504 --- /dev/null +++ b/TInterpreterProject.py @@ -0,0 +1,329 @@ +# -*- coding: utf-8 -*- +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +__author__ = "Rodrigo" +__date__ = "$18-sep-2012 12:35:06$" + +from components.TInterpreterTextArea import TInterpreterTextArea +from components.TInterpreterControlCell import TInterpreterControlCell +from components.TInterpreterAcumulatedCell import TInterpreterAcumulatedCell +from TInterpreterBoard import TInterpreterBoard +from components.TInterpreterCell import TInterpreterCell +import xml.etree.ElementTree as ET + +import pygtk +pygtk.require('2.0') +import gtk +import os + +import string + +class TInterpreterProject(gtk.VBox): + PROYECTOS = "proyectos" + + + def __init__(self): + super(TInterpreterProject, self).__init__() + self.currentBoard = None + self.boardList = {} + self.acumuladas = [] + self.acumuladasContainer = gtk.HBox(False, 0) + self.pack_end(self.acumuladasContainer) + self.show_all() + + self.barriendo = False + self.velActual = 2.0 + + def __getRealPath(self, path): + path = string.replace(path, "\\", os.sep) + path = string.replace(path, "/", os.sep) + + + salida = os.path.join(self.PROYECTOS, self.projectName, path) + return salida + + + + + + def XMLDecode(self, file): + tree = ET.parse(file) + root = tree.getroot() + + self.projectName = root.attrib["name"] + TInterpreterCell.projectName = self.projectName + self.initialBoard = root.find("initial_board").text + + for boardXML in root.findall("board"): + board = TInterpreterBoard() + board.setNombre(boardXML.attrib["name"]) + + model = boardXML.find("model") + + for attrXML in model.find("attributes").findall("attribute"): + key = attrXML.get("key") + + if key == "imageResizeStyle": + pass + elif key == "orderedCellList": + orderedCellList = [] + for cell in attrXML.findall("element"): + orderedCellList.append(cell.text) + board.setOrderedCellList(orderedCellList) + elif key == "size": + width = int(float(attrXML.find("width").text)) + height = int(float(attrXML.find("height").text)) + board.setOriginalSize((width, height)) + elif key == "soundFile": + pass + elif key == "icon": + pass + elif key == "backgroundColor": + board.setBackgroundColor(attrXML.text) + elif key == "gradientColor": + pass + + for compXML in model.findall("component"): + type = compXML.get("type") + + if type == "cell": + cell = TInterpreterCell() + + for attrXML in compXML.find("attributes").findall("attribute"): + key = attrXML.get("key") + + if key == "followingBoard": + cell.setFollowingBoard(attrXML.text, self.setCurrentBoard) + + elif key == "backgroundColor": + cell.setBackgroundColor(attrXML.text) + + elif key == "gradientColor": + pass + + elif key == "bordercolor": + cell.setBorderColor(attrXML.text) + + elif key == "linewidth": + cell.setBorderWidth(int(float(attrXML.text))) + + elif key=="environmentAction": + pass + + elif key=="alternativeBorderColor": + cell.setAlternativeBorderColor(attrXML.text) + + elif key=="alternativeLinewidth": + cell.setAlternativeBorderWidth(attrXML.text) + + elif key=="accumulated": + acumulable = True if attrXML.text == "true" else False + cell.setAcumulable(acumulable, self.acumular) + + elif key=="sendTextTimer": + pass + + elif key=="sendTextTarget": + cell.setSendTextTarget(attrXML.text) + + elif key=="sendText": + cell.setSendText(attrXML.text) + + elif key=="alternativeIcon": + cell.setAlternativeIcon(self.__getRealPath(attrXML.text)) + elif key=="verticalTextPosition": + cell.setVerticalTextPosition(attrXML.text) + + elif key=="soundFile": + cell.setSoundFile(self.__getRealPath(attrXML.text)) + + elif key=="alternativeSoundFile": + cell.setAlternativeSoundFile(self.__getRealPath(attrXML.text)) + + elif key=="voiceName": + pass + elif key=="voiceText": + cell.setVoiceText(attrXML.text) + elif key=="videoFile": + pass + elif key=="videoURL": + pass + + elif type == "controllerCell": + cell = TInterpreterControlCell() + + for attrXML in compXML.find("attributes").findall("attribute"): + key = attrXML.get("key") + + if key=="actionCode": + code = int(attrXML.text) + + if code == TInterpreterControlCell.EXIT_ACTION_CODE: + cell.setActionCode(code) + elif code == TInterpreterControlCell.UNDO_ACTION_CODE: + cell.setActionCode(code, self.desAcumular) + elif code == TInterpreterControlCell.UNDO_ALL_ACTION_CODE: + cell.setActionCode(code, self.desAcumularTodas) + elif code == TInterpreterControlCell.HOME_ACTION_CODE: + cell.setActionCode(code, self.irAInicial) + elif code==TInterpreterControlCell.READ_ACTION_CODE: + cell.setActionCode(code, self.readAcumuladas) + + + elif type == "line": + pass + + elif type == "oval": + pass + + elif type == "rectangle": + pass + + elif type == "textArea": + cell = TInterpreterTextArea() + + for attrXML in compXML.find("attributes").findall("attribute"): + + if key=="horizontalAlignment": + pass + elif key == "verticalAlignment": + pass + elif type == "roundRect": + pass + elif type=="label": + pass + + + #common attributes + if type == "cell" or type == "controllerCell": + for attrXML in compXML.find("attributes").findall("attribute"): + key = attrXML.get("key") + + if key == "font": + cell.setFontFamily(attrXML.find("family").text) + cell.setFontSize(int(attrXML.find("size").text)) + + bold = False if attrXML.find("bold") == None else True + cell.setFontBold(bold) + + italic = False if attrXML.find("italic") == None else True + cell.setFontBold(italic) + + elif key == "id": + cell.setId(attrXML.text) + + elif key=="foregroundColor": + cell.setForegroundColor(attrXML.text) + + elif key == "bounds": + x = int(float(attrXML.find("x").text)) + y = int(float(attrXML.find("y").text)) + width = int(float(attrXML.find("width").text)) + height = int(float(attrXML.find("height").text)) + + cell.setOriginalRect((x, y, width, height)) + + elif key == "text": + cell.setText(attrXML.text) + + elif key=="icon": + cell.setIcon(self.__getRealPath(attrXML.text)) + + + + + #agregar al tablero + if type == "cell" or type == "controllerCell": + board.addCell(cell) + + + + self.boardList[board.getNombre()] = board + + + +#========PROJECT ACTIONS======================================================== + + def setCurrentBoard(self, nombre): + if self.currentBoard != None: + if self.barriendo: + self.currentBoard.detenerBarrido() + self.remove(self.currentBoard) + + board = self.boardList[nombre] + board.initialize() + self.pack_start(board) + self.currentBoard = board + + if self.barriendo: + self.currentBoard.iniciarBarrido() + + + def acumular(self, cell): + acu = TInterpreterAcumulatedCell(cell) + self.acumuladasContainer.pack_start(acu, False, False, 0) + acu.set_size_request(acu.getWidth(), acu.getHeight()) + acu.show_all() + self.acumuladas.append(acu) + + def desAcumular(self): + if len(self.acumuladas) > 0: + self.acumuladasContainer.remove(self.acumuladas.pop()) + + def desAcumularTodas(self): + for acu in self.acumuladas: + self.acumuladasContainer.remove(acu) + self.acumuladas = [] + + def irAInicial(self): + self.setCurrentBoard(self.getInitialBoard()) + + def readAcumuladas(self): + for acu in self.acumuladas: + acu.leer() + + def barrido(self): + if not self.barriendo: + self.cambiarVelocidad(self.velActual) + self.currentBoard.iniciarBarrido() + self.barriendo = True + else: + self.currentBoard.detenerBarrido() + self.barriendo = False + + def cambiarVelocidad(self, value): + self.velActual = value + self.currentBoard.setVelocidadBarrido(value) + + + +#=========GET=================================================================== + + def getInitialBoard(self): + return self.initialBoard + + def getProjectName(self): + return self.projectName + + +if __name__ == "__main__": + x = TInterpreterProject() + x.XMLDecode("proyectos/Muestra/project.xml") diff --git a/Tixo.py b/Tixo.py new file mode 100644 index 0000000..97dc8be --- /dev/null +++ b/Tixo.py @@ -0,0 +1,123 @@ + +# -*- coding: utf-8 -*- +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +__author__ = "rodripf" +__date__ = "$28/09/2012 01:24:15 PM$" + +from TInterpreter import TInterpreter +from util.OpenNewProject import OpenNewProject +from util.ChooseProject import ChooseProject +import util.ControlFactory as ControlFactory + +from sugar.activity import activity + +import os +import pygtk +pygtk.require('2.0') +import gtk +import sugar + +from gettext import gettext as _ + +class Tixo(activity.Activity): + PROYECTOS = "proyectos" + + _NEW_TOOLBAR_SUPPORT = True + try: + from sugar.graphics.toolbarbox import ToolbarBox + from sugar.graphics.toolbarbox import ToolbarButton + from sugar.activity.widgets import StopButton + except: + _NEW_TOOLBAR_SUPPORT = False + + def __init__(self, handle, create_jobject=True): + activity.Activity.__init__(self, handle, False) + + def activityToolbar(toolbar): + ControlFactory.buttonFactory('open', toolbar, self.__abrir, tooltip=_('Abrir')) + ControlFactory.buttonFactory('barrido', toolbar, self.__barrer, tooltip=_('Barrido Automatico')) + ControlFactory.spinFactory(2.0, 0.5, 8.0, self.__cambioVelocidad, toolbar) + + + if self._NEW_TOOLBAR_SUPPORT: #toolbar nuevo + self.toolbar_box = sugar.graphics.toolbarbox.ToolbarBox() + + activityToolbar(self.toolbar_box.toolbar) + + stop_button = sugar.activity.widgets.StopButton(self) + stop_button.props.accelerator = 'Q' + self.toolbar_box.toolbar.insert(stop_button, -1) + stop_button.show() + + self.set_toolbar_box(self.toolbar_box) + self.toolbar_box.show() + + else: #old toolbar + toolbox = activity.ActivityToolbox(self) + + self.activity_tb = toolbox.get_activity_toolbar() + self.activity_tb.share.props.visible = False + self.activity_tb.keep.props.visible = False + + activityToolbar(self.activity_tb) + + self.activity_tb.show_all() + + self.set_toolbox(toolbox) + toolbox.show() + + self.activity = TInterpreter() + + self.set_canvas(self.activity.getContenedor()) + + def __abrir(self, widget): + abr = ChooseProject(self.PROYECTOS) + abr.addOnAbrirListener(self.__abierto) + abr.show() + + def __barrer(self, widget): + self.activity.barrido() + + def __abierto(self, proyName): + self.activity.load(os.path.join(self.PROYECTOS, proyName, "project.xml"),) + + def __cambioVelocidad(self, widget): + self.activity.cambiarVelocidad(widget.get_value()) + print widget.get_value() + + def close(self, skip_save=False): + activity.Activity.close(self, True) + + + def write_file(self, file_path): + self.metadata["hola"] = "hola" + print "hola" + + + def read_file(self, file_path): + try: + onp = OpenNewProject(file_path, self.metadata['title']) + self.__abierto(onp.getProjectName()) + except Exception, e: + print "Exception: ", e + + diff --git a/activity/Activity-TicoTico.svg b/activity/Activity-TicoTico.svg new file mode 100644 index 0000000..5800b75 --- /dev/null +++ b/activity/Activity-TicoTico.svg @@ -0,0 +1,119 @@ + + + +]> + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/activity/activity.info b/activity/activity.info new file mode 100644 index 0000000..a0c07d6 --- /dev/null +++ b/activity/activity.info @@ -0,0 +1,9 @@ +[Activity] +name = TIXO +service_name = org.teleton.ingenieria.TIXO +exec = sugar-activity Tixo.Tixo +icon = Activity-TicoTico +activity_version = 1 +license = GPLv3+ +show_launcher = yes +mime_types = application/octet-stream diff --git a/activity/activity.info~ b/activity/activity.info~ new file mode 100644 index 0000000..a00caae --- /dev/null +++ b/activity/activity.info~ @@ -0,0 +1,9 @@ +[Activity] +name = TIXO +service_name = org.teleton.ingenieria.TIXO +exec = sugar-activity Tixo.Tixo +icon = Activity-TicoTico +activity_version = 2 +license = GPLv3+ +show_launcher = yes +mime_types = application/octet-stream diff --git a/components/TInterpreterAcumulatedCell.py b/components/TInterpreterAcumulatedCell.py new file mode 100644 index 0000000..6420278 --- /dev/null +++ b/components/TInterpreterAcumulatedCell.py @@ -0,0 +1,52 @@ +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +__author__="Rodrigo" +__date__ ="$21-sep-2012 12:21:37$" + +from components.TInterpreterCommonCell import TInterpreterCommonCell +import pygtk +pygtk.require('2.0') +import gtk + +class TInterpreterAcumulatedCell(TInterpreterCommonCell): + + def __init__(self, original): + self._original = original + super(TInterpreterAcumulatedCell, self).__init__() + self.setText(original.getText()) + self.setIcon(original.getIcon()) + self.initialize() + + def getOriginal(self): + return self._original + + def getHeight(self): + return 100 + + def getWidth(self): + return 80 + + def getId(self): + return self._original.getId() + + +if __name__ == "__main__": + print "Hello World" diff --git a/components/TInterpreterCell.py b/components/TInterpreterCell.py new file mode 100644 index 0000000..fdb1a4a --- /dev/null +++ b/components/TInterpreterCell.py @@ -0,0 +1,124 @@ +import TInterpreterProject +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +__author__="Rodrigo" +__date__ ="$20-sep-2012 11:11:29$" + +import speak.espeak_cmd as espeak_cmd +import speak.GoogleTTS as GoogleTTS + +from components.TInterpreterCommonCell import TInterpreterCommonCell +from threads.TInterpreterPlaySound import TInterpreterPlaySound +import pygtk +pygtk.require('2.0') +import gtk + + + +class TInterpreterCell(TInterpreterCommonCell): + projectName = "" + + + def __init__(self): + super(TInterpreterCell, self).__init__() + self.connect("clicked", self.onClick) +# self.connect("enter", self.onMouseOver) +# self.connect("enter", self.onMouseOut(widget)) + + self._FollowingBoard = None + self._Acumulable = False + self._AlternativeIcon = None + self._SoundFile = None + self._VoiceText = None + + +#========SETUP FUNCTIONS======================================================== + + def setSendTextTarget(self, value): + self._SendTextTarget = value + + def setSendText(self, value): + self._SendText = value + + def setAlternativeIcon(self, value): + self._AlternativeIcon = value + + + def setSoundFile(self, value): + self._SoundFile = value + + def setAlternativeSoundFile(self, value): + self._AlternativeSoundFile = value + + def setVoiceText(self, value): + self._VoiceText = value + + +#=======ADD LISTENERS=========================================================== + + def setFollowingBoard(self, value, action): + self._FollowingBoard = value + self._actionChangeBoard = action + + + def setAcumulable(self, value, action): + self._Acumulable = value + self._actionAcumulable = action + + + + + + +#=======ON EVENTS========================================================== + + def sonido(self): + t = TInterpreterPlaySound((self._SoundFile,)) + t.start() + + def sintetizar(self): + funciono = GoogleTTS.intentar(TInterpreterCell.projectName, self._VoiceText) + if not funciono: + espeak_cmd.hablar(self._VoiceText) + + def onMouseOver(self, widget): + if self._AlternativeIcon: + self.deInitialize() + self.add(self.loadImage(img = self._AlternativeIcon)) + + def onMouseOut(self, widget): + self.initialize() + + def onClick(self, widget): + if self._Acumulable: + self._actionAcumulable(self) + + if self._SoundFile: + self.sonido() + + if self._VoiceText: + self.sintetizar() + + if self._FollowingBoard != None: + self._actionChangeBoard(self._FollowingBoard) + +if __name__ == "__main__": + print "Hello World" diff --git a/components/TInterpreterCommonCell.py b/components/TInterpreterCommonCell.py new file mode 100644 index 0000000..538f7b8 --- /dev/null +++ b/components/TInterpreterCommonCell.py @@ -0,0 +1,153 @@ +__author__="Rodrigo" +__date__ ="$21-sep-2012 12:25:32$" + +from components.TInterpreterCommonControl import TInterpreterCommonControl +import pygtk +pygtk.require('2.0') +import gtk +import pango + +class TInterpreterCommonCell(gtk.Button, TInterpreterCommonControl): +#=======SETUP========================================================== + + def __init__(self): + super(TInterpreterCommonCell, self).__init__() + self._VerticalTextPosition = 0 + self._Icon = None + self._Text = None + self.BackgroundColor = None; + + + def setIcon(self, value): + self._Icon = value + + def getIcon(self): + return self._Icon + + def setAlternativeBorderColor(self, value): + self._AlternativeBorderColor = value + + def setAlternativeBorderWidth(self, value): + self._AlternativeBorderWidth = value + + def setVerticalTextPosition(self, value): + self._VerticalTextPosition = value + + def setId(self, value): + #self.set_label(value) + self._Id = value + +#========GET FUNCTIONS======================================================== + def getId(self): + return self._Id + + def getX(self): + return self._OriginalRect[0] + + def getY(self): + return self._OriginalRect[1] + + def getWidth(self): + return self._OriginalRect[2] + + def getHeight(self): + return self._OriginalRect[3] + + +#=======COLORIZE================================================================ + + def resaltar(self): + color = self.get_colormap().alloc_color("#ff0000") + + self.modify_bg(gtk.STATE_NORMAL, color) + self.modify_bg(gtk.STATE_ACTIVE, color) + self.modify_base(gtk.STATE_NORMAL, color) + self.modify_bg(gtk.STATE_PRELIGHT, color) + + self.grab_focus() + + def desResaltar(self): + color = self.get_colormap().alloc_color("#" + self.BackgroundColor.upper()[2:]) + + self.modify_bg(gtk.STATE_NORMAL, color) + self.modify_bg(gtk.STATE_PRELIGHT, color) + + +#=======Events Handlers========================================================= + def onMouseOver(self, widget): + pass + + def onMouseOut(self, widget): + pass + + def onClick(self, widget): + pass + + + +#=======INITIALIZATION========================================================== + def initialize(self): + #bacground color + #make a gdk.color for red + + if self.BackgroundColor: + color = self.get_colormap().alloc_color("#" + self.BackgroundColor.upper()[2:]) + + self.modify_bg(gtk.STATE_NORMAL, color) + self.modify_bg(gtk.STATE_PRELIGHT, color) + + + + + if self._Text != None and self._Icon != None: + vbox = gtk.VBox(False, 0) + lbl = gtk.Label(self._Text) + if self._VerticalTextPosition == 3: #bottom + vbox.pack_start(self.loadImage(True)) + vbox.pack_end(lbl) + else: #top or center = top + vbox.pack_start(lbl, False, False, 0) + vbox.pack_end(self.loadImage(True), False, False, 0) + + self.add(vbox) + text = lbl + + elif self._Text!=None: + self.set_label(self._Text) + text = self + elif self._Icon != None: + self.add(self.loadImage()) + text = self + + if self._ForegroundColor: + color = self.get_colormap().alloc_color("#" + self._ForegroundColor.upper()[2:]) + text.modify_fg(gtk.STATE_NORMAL, color) + text.modify_fg(gtk.STATE_PRELIGHT, color) + else: + color = self.get_colormap().alloc_color("black") + text.modify_fg(gtk.STATE_NORMAL, color) + text.modify_fg(gtk.STATE_PRELIGHT, color) + + if self._FontSize: + text.modify_font(pango.FontDescription("sans " + str(self._FontSize))) + + def deInitialize(self): + children = self.get_children() + for child in children: + self.remove(child) + + def loadImage(self, texto = False, img = None): + image = gtk.Image() + if img==None: + img = self._Icon + pixbuf = gtk.gdk.pixbuf_new_from_file(img) + + maxW = float(self.getWidth()) + maxH = float(self.getHeight() if not texto else self.getHeight() - self._FontSize * 4) + + im = pixbuf.scale_simple(int(maxW - 10), int(maxH - 10), gtk.gdk.INTERP_BILINEAR) + image.set_from_pixbuf(im) + return image + +if __name__ == "__main__": + print "Hello World" diff --git a/components/TInterpreterCommonCell.py~ b/components/TInterpreterCommonCell.py~ new file mode 100644 index 0000000..78809ef --- /dev/null +++ b/components/TInterpreterCommonCell.py~ @@ -0,0 +1,149 @@ +__author__="Rodrigo" +__date__ ="$21-sep-2012 12:25:32$" + +from components.TInterpreterCommonControl import TInterpreterCommonControl +import pygtk +pygtk.require('2.0') +import gtk +import pango + +class TInterpreterCommonCell(gtk.Button, TInterpreterCommonControl): +#=======SETUP========================================================== + + def __init__(self): + super(TInterpreterCommonCell, self).__init__() + self._VerticalTextPosition = 0 + self._Icon = None + self._Text = None + self.BackgroundColor = None; + + + def setIcon(self, value): + self._Icon = value + + def getIcon(self): + return self._Icon + + def setAlternativeBorderColor(self, value): + self._AlternativeBorderColor = value + + def setAlternativeBorderWidth(self, value): + self._AlternativeBorderWidth = value + + def setVerticalTextPosition(self, value): + self._VerticalTextPosition = value + + def setId(self, value): + #self.set_label(value) + self._Id = value + +#========GET FUNCTIONS======================================================== + def getId(self): + return self._Id + + def getX(self): + return self._OriginalRect[0] + + def getY(self): + return self._OriginalRect[1] + + def getWidth(self): + return self._OriginalRect[2] + + def getHeight(self): + return self._OriginalRect[3] + + +#=======COLORIZE================================================================ + + def resaltar(self): + color = self.get_colormap().alloc_color("#ff0000") + + self.modify_bg(gtk.STATE_NORMAL, color) + self.modify_bg(gtk.STATE_PRELIGHT, color) + + def desResaltar(self): + color = self.get_colormap().alloc_color("#" + self.BackgroundColor.upper()[2:]) + + self.modify_bg(gtk.STATE_NORMAL, color) + self.modify_bg(gtk.STATE_PRELIGHT, color) + + +#=======Events Handlers========================================================= + def onMouseOver(self, widget): + pass + + def onMouseOut(self, widget): + pass + + def onClick(self, widget): + pass + + + +#=======INITIALIZATION========================================================== + def initialize(self): + #bacground color + #make a gdk.color for red + + if self.BackgroundColor: + color = self.get_colormap().alloc_color("#" + self.BackgroundColor.upper()[2:]) + + self.modify_bg(gtk.STATE_NORMAL, color) + self.modify_bg(gtk.STATE_PRELIGHT, color) + + + + + if self._Text != None and self._Icon != None: + vbox = gtk.VBox(False, 0) + lbl = gtk.Label(self._Text) + if self._VerticalTextPosition == 3: #bottom + vbox.pack_start(self.loadImage(True)) + vbox.pack_end(lbl) + else: #top or center = top + vbox.pack_start(lbl, False, False, 0) + vbox.pack_end(self.loadImage(True), False, False, 0) + + self.add(vbox) + text = lbl + + elif self._Text!=None: + self.set_label(self._Text) + text = self + elif self._Icon != None: + self.add(self.loadImage()) + text = self + + if self._ForegroundColor: + color = self.get_colormap().alloc_color("#" + self._ForegroundColor.upper()[2:]) + text.modify_fg(gtk.STATE_NORMAL, color) + text.modify_fg(gtk.STATE_PRELIGHT, color) + else: + color = self.get_colormap().alloc_color("black") + text.modify_fg(gtk.STATE_NORMAL, color) + text.modify_fg(gtk.STATE_PRELIGHT, color) + + if self._FontSize: + text.modify_font(pango.FontDescription("sans " + str(self._FontSize))) + + def deInitialize(self): + children = self.get_children() + for child in children: + self.remove(child) + + def loadImage(self, texto = False, img = None): + image = gtk.Image() + if img==None: + img = self._Icon + pixbuf = gtk.gdk.pixbuf_new_from_file(img) + + maxW = float(self.getWidth()) + maxH = float(self.getHeight() if not texto else self.getHeight() - self._FontSize * 4) + + im = pixbuf.scale_simple(int(maxW - 10), int(maxH - 10), gtk.gdk.INTERP_BILINEAR) + image.set_from_pixbuf(im) + return image + +if __name__ == "__main__": + print "Hello World" diff --git a/components/TInterpreterCommonControl.py b/components/TInterpreterCommonControl.py new file mode 100644 index 0000000..7e2e57e --- /dev/null +++ b/components/TInterpreterCommonControl.py @@ -0,0 +1,47 @@ +__author__="Rodrigo" +__date__ ="$25-sep-2012 14:47:44$" + +class TInterpreterCommonControl: + def __init__(self): + self._ForegroundColor = None + self.BackgroundColor = None + self._FontFamily = None + self._FontSize = None + pass + + def setBackgroundColor(self, value): + self.BackgroundColor = value + + + def setOriginalRect(self, value): + self._OriginalRect = value + + def setFontFamily(self, value): + self._FontFamily = value + + def setFontSize(self, value): + self._FontSize = value + + def setFontBold(self, value): + self._FontBold = value + + def setFontItalic(self, value): + self._FontItalic = value + + def setForegroundColor(self, value): + self._ForegroundColor=value + + def setText(self, value): + self._Text = value + + def setBorderWidth(self, value): + self._BorderWidth = value + + def setBorderColor(self, value): + self._BorderColor = value + + def getText(self): + return self._Text + +if __name__ == "__main__": + print "Hello World"; diff --git a/components/TInterpreterConstants.py b/components/TInterpreterConstants.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/components/TInterpreterConstants.py diff --git a/components/TInterpreterControlCell.py b/components/TInterpreterControlCell.py new file mode 100644 index 0000000..4067257 --- /dev/null +++ b/components/TInterpreterControlCell.py @@ -0,0 +1,60 @@ +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from components.TInterpreterCommonCell import TInterpreterCommonCell +__author__="Rodrigo" +__date__ ="$25-sep-2012 14:28:49$" + +import pygtk +pygtk.require('2.0') +import gtk + + +class TInterpreterControlCell(TInterpreterCommonCell): + EXIT_ACTION_CODE = 1 + UNDO_ACTION_CODE = 2 + UNDO_ALL_ACTION_CODE = 3 + READ_ACTION_CODE = 4 + RETURN_ACTION_CODE = 5 + STOP_ACTION_CODE = 6 + HOME_ACTION_CODE = 7 + COPY_ACTION_CODE = 8 + + def __init__(self): + super(TInterpreterControlCell, self).__init__() + self.connect("clicked", self.onClick) + + def setActionCode(self, value, action = None): + self._ActionCode = value + + if action!= None: + self._action = action + + + +#=======ON EVENTS========================================================== + + def onClick(self, widget): + if self._ActionCode == self.EXIT_ACTION_CODE: + gtk.main_quit() + else: + self._action() + + diff --git a/components/TInterpreterTextArea.py b/components/TInterpreterTextArea.py new file mode 100644 index 0000000..6b81c28 --- /dev/null +++ b/components/TInterpreterTextArea.py @@ -0,0 +1,10 @@ +from components.TInterpreterCommonControl import TInterpreterCommonControl +import pygtk +pygtk.require('2.0') +import gtk +__author__="Rodrigo" +__date__ ="$26-sep-2012 10:50:05$" + +class TInterpreterTextArea(TInterpreterCommonControl, gtk.Entry): + def __init__(self): + super(TInterpreterTextArea, self).__init__() \ No newline at end of file diff --git a/components/__init__.py b/components/__init__.py new file mode 100644 index 0000000..a5fb98d --- /dev/null +++ b/components/__init__.py @@ -0,0 +1,2 @@ +__author__="Rodrigo" +__date__ ="$20-sep-2012 11:27:27$" \ No newline at end of file diff --git a/components/rules/__init__.py b/components/rules/__init__.py new file mode 100644 index 0000000..a5fb98d --- /dev/null +++ b/components/rules/__init__.py @@ -0,0 +1,2 @@ +__author__="Rodrigo" +__date__ ="$20-sep-2012 11:27:27$" \ No newline at end of file diff --git a/dist/TIXO-1.xo b/dist/TIXO-1.xo new file mode 100644 index 0000000..7f18892 --- /dev/null +++ b/dist/TIXO-1.xo Binary files differ diff --git a/dist/TIXO-2.xo b/dist/TIXO-2.xo new file mode 100644 index 0000000..ae0f27d --- /dev/null +++ b/dist/TIXO-2.xo Binary files differ diff --git a/generar.sh b/generar.sh new file mode 100644 index 0000000..47a95ac --- /dev/null +++ b/generar.sh @@ -0,0 +1,29 @@ +if ! 'rm -r */*.pyc'; then + echo 'No hay pyc para borrar' +else + echo 'Se borraron los pyc' +fi 2>/dev/null + +if ! 'rm -r ./proyectos/*'; then + echo 'No hay proyectos para borrar' +else + echo 'Se borraron los proyectos' +fi 2>/dev/null + +if ! './setup.py' 'genpot'; then + echo 'No se pudo generar pot' +else + echo 'Se genero pot' +fi 2>/dev/null + +if ! './setup.py' 'fix_manifest'; then + echo 'No se pudo arreglar el manifest' +else + echo 'Se arreglo el manifest' +fi 2>/dev/null + +if ! './setup.py' 'dist_xo'; then + echo 'Hubo un error al generar el .XO' +else + echo 'Se genero el .XO en la carpeta ./dist/' +fi 2>/dev/null diff --git a/icons/barrido.svg b/icons/barrido.svg new file mode 100644 index 0000000..78afad8 --- /dev/null +++ b/icons/barrido.svg @@ -0,0 +1,210 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + r2r2r23r23r23r23r23r + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/open.svg b/icons/open.svg new file mode 100644 index 0000000..64ce481 --- /dev/null +++ b/icons/open.svg @@ -0,0 +1,57 @@ + +image/svg+xml + + + + + \ No newline at end of file diff --git a/po/TIXO.pot b/po/TIXO.pot new file mode 100644 index 0000000..57df67e --- /dev/null +++ b/po/TIXO.pot @@ -0,0 +1,163 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-12-17 12:26+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: activity/activity.info:2 +msgid "TIXO" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/Tixo.py:54 +msgid "Abrir" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/Tixo.py:55 +msgid "Barrido Automatico" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:35 +msgid "Brazil" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:36 +msgid "Swedish" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:37 +msgid "Icelandic" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:38 +msgid "Romanian" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:39 +msgid "Swahili" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:40 +msgid "Hindi" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:41 +msgid "Dutch" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:42 +msgid "Latin" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:43 +msgid "Hungarian" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:44 +msgid "Macedonian" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:45 +msgid "Welsh" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:46 +msgid "French" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:47 +msgid "Norwegian" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:48 +msgid "Russian" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:49 +msgid "Afrikaans" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:50 +msgid "Finnish" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:51 +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:154 +msgid "Default" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:52 +msgid "Cantonese" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:53 +msgid "Scottish" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:54 +msgid "Greek" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:55 +msgid "Vietnam" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:56 +msgid "English" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:57 +msgid "Lancashire" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:58 +msgid "Italian" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:59 +msgid "Portugal" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:60 +msgid "German" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:61 +msgid "Whisper" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:62 +msgid "Croatian" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:63 +msgid "Czech" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:64 +msgid "Slovak" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:65 +msgid "Spanish" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:66 +msgid "Polish" +msgstr "" + +#: /home/rodripf/Programacion/TicoPython/src/speak/voice.py:67 +msgid "Esperanto" +msgstr "" diff --git a/proyectos/.empty b/proyectos/.empty new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/proyectos/.empty diff --git a/proyectos/Muestra/image/2245.png b/proyectos/Muestra/image/2245.png new file mode 100644 index 0000000..ca8be16 --- /dev/null +++ b/proyectos/Muestra/image/2245.png Binary files differ diff --git a/proyectos/Muestra/image/2300.png b/proyectos/Muestra/image/2300.png new file mode 100644 index 0000000..de87812 --- /dev/null +++ b/proyectos/Muestra/image/2300.png Binary files differ diff --git a/proyectos/Muestra/image/2304_1.png b/proyectos/Muestra/image/2304_1.png new file mode 100644 index 0000000..483589f --- /dev/null +++ b/proyectos/Muestra/image/2304_1.png Binary files differ diff --git a/proyectos/Muestra/image/2314.png b/proyectos/Muestra/image/2314.png new file mode 100644 index 0000000..b302727 --- /dev/null +++ b/proyectos/Muestra/image/2314.png Binary files differ diff --git a/proyectos/Muestra/image/2349.png b/proyectos/Muestra/image/2349.png new file mode 100644 index 0000000..0315d67 --- /dev/null +++ b/proyectos/Muestra/image/2349.png Binary files differ diff --git a/proyectos/Muestra/image/2367.png b/proyectos/Muestra/image/2367.png new file mode 100644 index 0000000..ecd0e0d --- /dev/null +++ b/proyectos/Muestra/image/2367.png Binary files differ diff --git a/proyectos/Muestra/image/2370.png b/proyectos/Muestra/image/2370.png new file mode 100644 index 0000000..06ac16f --- /dev/null +++ b/proyectos/Muestra/image/2370.png Binary files differ diff --git a/proyectos/Muestra/image/2374.png b/proyectos/Muestra/image/2374.png new file mode 100644 index 0000000..1a2ed1b --- /dev/null +++ b/proyectos/Muestra/image/2374.png Binary files differ diff --git a/proyectos/Muestra/image/2401.png b/proyectos/Muestra/image/2401.png new file mode 100644 index 0000000..519b232 --- /dev/null +++ b/proyectos/Muestra/image/2401.png Binary files differ diff --git a/proyectos/Muestra/image/2430.png b/proyectos/Muestra/image/2430.png new file mode 100644 index 0000000..dd722ef --- /dev/null +++ b/proyectos/Muestra/image/2430.png Binary files differ diff --git a/proyectos/Muestra/image/24735.png b/proyectos/Muestra/image/24735.png new file mode 100644 index 0000000..50c3ff9 --- /dev/null +++ b/proyectos/Muestra/image/24735.png Binary files differ diff --git a/proyectos/Muestra/image/24795.png b/proyectos/Muestra/image/24795.png new file mode 100644 index 0000000..0646d6d --- /dev/null +++ b/proyectos/Muestra/image/24795.png Binary files differ diff --git a/proyectos/Muestra/image/2487.png b/proyectos/Muestra/image/2487.png new file mode 100644 index 0000000..67c6a4f --- /dev/null +++ b/proyectos/Muestra/image/2487.png Binary files differ diff --git a/proyectos/Muestra/image/25191.png b/proyectos/Muestra/image/25191.png new file mode 100644 index 0000000..f700492 --- /dev/null +++ b/proyectos/Muestra/image/25191.png Binary files differ diff --git a/proyectos/Muestra/image/2586.png b/proyectos/Muestra/image/2586.png new file mode 100644 index 0000000..0204c17 --- /dev/null +++ b/proyectos/Muestra/image/2586.png Binary files differ diff --git a/proyectos/Muestra/image/2587.png b/proyectos/Muestra/image/2587.png new file mode 100644 index 0000000..d2e52d3 --- /dev/null +++ b/proyectos/Muestra/image/2587.png Binary files differ diff --git a/proyectos/Muestra/image/2606.png b/proyectos/Muestra/image/2606.png new file mode 100644 index 0000000..963b8ad --- /dev/null +++ b/proyectos/Muestra/image/2606.png Binary files differ diff --git a/proyectos/Muestra/image/2684.png b/proyectos/Muestra/image/2684.png new file mode 100644 index 0000000..f7f2665 --- /dev/null +++ b/proyectos/Muestra/image/2684.png Binary files differ diff --git a/proyectos/Muestra/image/3250.png b/proyectos/Muestra/image/3250.png new file mode 100644 index 0000000..e7c9562 --- /dev/null +++ b/proyectos/Muestra/image/3250.png Binary files differ diff --git a/proyectos/Muestra/image/4962.png b/proyectos/Muestra/image/4962.png new file mode 100644 index 0000000..58126c1 --- /dev/null +++ b/proyectos/Muestra/image/4962.png Binary files differ diff --git a/proyectos/Muestra/image/5441.png b/proyectos/Muestra/image/5441.png new file mode 100644 index 0000000..46930f5 --- /dev/null +++ b/proyectos/Muestra/image/5441.png Binary files differ diff --git a/proyectos/Muestra/image/5957_1.png b/proyectos/Muestra/image/5957_1.png new file mode 100644 index 0000000..e012fac --- /dev/null +++ b/proyectos/Muestra/image/5957_1.png Binary files differ diff --git a/proyectos/Muestra/image/6522.png b/proyectos/Muestra/image/6522.png new file mode 100644 index 0000000..c5991f1 --- /dev/null +++ b/proyectos/Muestra/image/6522.png Binary files differ diff --git a/proyectos/Muestra/image/6537.png b/proyectos/Muestra/image/6537.png new file mode 100644 index 0000000..70a0509 --- /dev/null +++ b/proyectos/Muestra/image/6537.png Binary files differ diff --git a/proyectos/Muestra/image/6625_1.png b/proyectos/Muestra/image/6625_1.png new file mode 100644 index 0000000..bbef981 --- /dev/null +++ b/proyectos/Muestra/image/6625_1.png Binary files differ diff --git a/proyectos/Muestra/image/6632_1.png b/proyectos/Muestra/image/6632_1.png new file mode 100644 index 0000000..f20147b --- /dev/null +++ b/proyectos/Muestra/image/6632_1.png Binary files differ diff --git a/proyectos/Muestra/image/7061.png b/proyectos/Muestra/image/7061.png new file mode 100644 index 0000000..3e7400d --- /dev/null +++ b/proyectos/Muestra/image/7061.png Binary files differ diff --git a/proyectos/Muestra/image/8662.png b/proyectos/Muestra/image/8662.png new file mode 100644 index 0000000..47920c6 --- /dev/null +++ b/proyectos/Muestra/image/8662.png Binary files differ diff --git a/proyectos/Muestra/image/controller-home.png b/proyectos/Muestra/image/controller-home.png new file mode 100644 index 0000000..5c12451 --- /dev/null +++ b/proyectos/Muestra/image/controller-home.png Binary files differ diff --git a/proyectos/Muestra/image/controller-home_1.png b/proyectos/Muestra/image/controller-home_1.png new file mode 100644 index 0000000..5c12451 --- /dev/null +++ b/proyectos/Muestra/image/controller-home_1.png Binary files differ diff --git a/proyectos/Muestra/image/teleton.png b/proyectos/Muestra/image/teleton.png new file mode 100644 index 0000000..f2fc1a2 --- /dev/null +++ b/proyectos/Muestra/image/teleton.png Binary files differ diff --git a/proyectos/Muestra/project.xml b/proyectos/Muestra/project.xml new file mode 100644 index 0000000..ae26f0b --- /dev/null +++ b/proyectos/Muestra/project.xml @@ -0,0 +1,888 @@ + + + + board_0 + + + + + cell_0 + cell_1 + cell_16 + cell_17 + cell_2 + cell_3 + + ff3465a4 + + cell_19 + + 0 + + 1024.0 + 600.0 + + + + + + Arial + 12 + + ffff0000 + cell_0 + 3 + 4 + 1.0 + image\6522.png + HOLA + ff000000 + Hola + ff000000 + + 11.0 + 28.0 + 190.0 + 192.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_1 + 3 + 4 + 1.0 + image\6625_1.png + ¿CÓMO ESTÁS? + ff000000 + ¿Cómo estás? + ff000000 + + 271.0 + 28.0 + 190.0 + 192.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + board_1 + cell_2 + 3 + 4 + 1.0 + image\2684.png + ESTOY... + ff000000 + Yo estoy + ff000000 + + 519.0 + 305.0 + 202.0 + 185.0 + + ff73d216 + false + + + + + + Arial + 12 + + ffff0000 + board_2 + cell_3 + 3 + 4 + 1.0 + image\5441.png + QUIERO... + ff000000 + Quiero + ff000000 + + 779.0 + 305.0 + 202.0 + 186.0 + + fffcaf3e + false + + + + + + Arial + 12 + + ffff0000 + cell_16 + 3 + 4 + 1.0 + image\6632_1.png + ME LLAMO... + ff000000 + Me llamo ántony + ff000000 + + 531.0 + 28.0 + 190.0 + 192.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_17 + 3 + 4 + 1.0 + image\7061.png + ¿CÓMO TE LLAMAS? + ff000000 + ¿Cómo te llamas? + ff000000 + + 791.0 + 28.0 + 190.0 + 192.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_19 + 3 + 4 + 1.0 + image\teleton.png + + ff000000 + Teletón Uruguay + ff000000 + + 86.0 + 304.0 + 237.0 + 237.0 + + ffffffff + false + + + + + + + + + cell_4 + cell_5 + cell_12 + cell_11 + cell_6 + cell_7 + cell_13 + cell_14 + cell_8 + cell_9 + cell_10 + controller_cell_0 + + ff73d216 + + 0 + + 1024.0 + 600.0 + + + + + + Arial + 12 + + ffff0000 + cell_4 + 3 + 4 + 1.0 + image\3250.png + FELIZ + ff000000 + feliz + ff000000 + + 19.0 + 15.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_5 + 3 + 4 + 1.0 + image\2606.png + TRISTE + ff000000 + triste + ff000000 + + 291.3333333333333 + 15.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_6 + 3 + 4 + 1.0 + image\24735.png + DIVERTIDO + ff000000 + Divertido + ff000000 + + 19.0 + 215.5 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_7 + 3 + 4 + 1.0 + image\2245.png + ABURRIDO + ff000000 + Aburrido + ff000000 + + 291.3333333333333 + 215.5 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_8 + 3 + 4 + 1.0 + image\2401.png + CON FRÍO + ff000000 + con frío + ff000000 + + 19.0 + 416.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_9 + 3 + 4 + 1.0 + image\2300.png + CALOR + ff000000 + con calor + ff000000 + + 291.3333333333333 + 416.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_10 + 3 + 4 + 1.0 + image\2314.png + SUEÑO + ff000000 + con sueño + ff000000 + + 563.6666666666666 + 416.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_11 + 3 + 4 + 1.0 + image\2367.png + DOLOR + ff000000 + con dolor + ff000000 + + 836.0 + 15.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_12 + 3 + 4 + 1.0 + image\2374.png + ENOJADO + ff000000 + enojado + ff000000 + + 563.6666666666666 + 15.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_13 + 3 + 4 + 1.0 + image\4962.png + HAMBRE + ff000000 + con hambre + ff000000 + + 563.6666666666666 + 215.5 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_14 + 3 + 4 + 1.0 + image\8662.png + PREOCUPADO + ff000000 + preocupado + ff000000 + + 836.0 + 215.5 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + controller_cell_0 + 3 + 4 + 1.0 + image\controller-home.png + Inicio + 7 + ff000000 + ff000000 + + 836.0 + 416.0 + 168.0 + 158.0 + + ffffffff + + + + + + + + + cell_4 + cell_5 + cell_12 + cell_11 + cell_6 + cell_7 + cell_13 + cell_14 + cell_8 + cell_9 + cell_10 + controller_cell_0 + + fffcaf3e + + 0 + + 1024.0 + 600.0 + + + + + + Arial + 12 + + ffff0000 + cell_4 + 3 + 4 + 1.0 + image\2349.png + COMER + ff000000 + comer + ff000000 + + 19.0 + 15.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_5 + 3 + 4 + 1.0 + image\2430.png + IR AL BAÑO + ff000000 + ir al baño + ff000000 + + 291.3333333333333 + 15.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_6 + 3 + 4 + 1.0 + image\6537.png + JUGAR + ff000000 + jugar + ff000000 + + 19.0 + 215.5 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_7 + 3 + 4 + 1.0 + image\2587.png + VER TELE + ff000000 + ver tele + ff000000 + + 291.3333333333333 + 215.5 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_8 + 3 + 4 + 1.0 + image\2586.png + USAR EL TELÉFONO + ff000000 + usar el teléfono + ff000000 + + 19.0 + 416.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_9 + 3 + 4 + 1.0 + image\5957_1.png + ir a casa + ff000000 + ir a casa + ff000000 + + 291.3333333333333 + 416.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_10 + 3 + 4 + 1.0 + image\25191.png + LEER + ff000000 + leer + ff000000 + + 563.6666666666666 + 416.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_11 + 3 + 4 + 1.0 + image\2304_1.png + DORMIR + ff000000 + dormir + ff000000 + + 836.0 + 15.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_12 + 3 + 4 + 1.0 + image\2370.png + BAÑARME + ff000000 + bañarme + ff000000 + + 563.6666666666666 + 15.0 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_13 + 3 + 4 + 1.0 + image\24795.png + ESCUCHAR MUSICA + ff000000 + escuchar música + ff000000 + + 563.6666666666666 + 215.5 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + cell_14 + 3 + 4 + 1.0 + image\2487.png + COMPUTADORA + ff000000 + usar la computadora + ff000000 + + 836.0 + 215.5 + 168.0 + 158.0 + + ffffffff + false + + + + + + Arial + 12 + + ffff0000 + controller_cell_0 + 3 + 4 + 1.0 + image\controller-home_1.png + Inicio + 7 + ff000000 + ff000000 + + 836.0 + 416.0 + 168.0 + 158.0 + + ffffffff + + + + + \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6ea61a6 --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +#!/usr/bin/python +from sugar.activity import bundlebuilder +bundlebuilder.start() diff --git a/speak/GoogleTTS.py b/speak/GoogleTTS.py new file mode 100644 index 0000000..79a0ae0 --- /dev/null +++ b/speak/GoogleTTS.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +import os +import os.path +import string +import urllib2 +from threads.TInterpreterPlaySound import TInterpreterPlaySound + + +def __internetOn(): + try: + urllib2.urlopen('http://www.google.com',timeout=1) + return True + except urllib2.URLError as err: + pass + return False + +def intentar(projectName, texto): + texto = texto.split(" ") + texto = string.join(texto, "+") + + destino = os.path.join("proyectos", projectName, texto + ".mp3") + if os.path.exists(destino): #ya lo tengo, lo reproduzco + t = TInterpreterPlaySound([destino, ]) + t.start() + return True + else: #no lo tengo + if __internetOn(): #hay internet + os.system("wget -q -U Mozilla -O \"" + destino + "\" \"http://translate.google.com/translate_tts?ie=UTF-8&tl=es&q=" + texto + "\"") + t = TInterpreterPlaySound([destino, ]) + t.start() + return True + else: #no hay internet y no lo tengo + return False diff --git a/speak/__init__.py b/speak/__init__.py new file mode 100644 index 0000000..431e730 --- /dev/null +++ b/speak/__init__.py @@ -0,0 +1,2 @@ +__author__="rodripf" +__date__ ="$28/09/2012 12:37:08 PM$" \ No newline at end of file diff --git a/speak/espeak_cmd.py b/speak/espeak_cmd.py new file mode 100644 index 0000000..26116dd --- /dev/null +++ b/speak/espeak_cmd.py @@ -0,0 +1,64 @@ +# Adapted from the activity Speak http://activities.sugarlabs.org/es-ES/sugar/addon/4038 +# Copyright (C) 2009, Aleksey Lim +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import re +import subprocess + +PITCH_MAX = 99 +RATE_MAX = 99 +PITCH_DEFAULT = PITCH_MAX/2 +RATE_DEFAULT = RATE_MAX/3 + +import voice + +def speak(text, rate=RATE_DEFAULT, pitch=PITCH_DEFAULT, + voice="default"): + + # espeak uses 80 to 370 + rate = 80 + (370-80) * int(rate) / 100 + + subprocess.call(["espeak", "-p", str(pitch), + "-s", str(rate), "-v", voice, text], + stdout=subprocess.PIPE) + +def voices(): + out = [] + result = subprocess.Popen(["espeak", "--voices"], + stdout=subprocess.PIPE).communicate()[0] + + for line in result.split('\n'): + m = re.match( + r'\s*\d+\s+([\w-]+)\s+([MF])\s+([\w_-]+)\s+(.+)', + line) + if not m: + continue + language, gender, name, stuff = m.groups() + if stuff.startswith('mb/') or \ + name in ('en-rhotic','english_rp', + 'english_wmids'): + # these voices don't produce sound + continue + out.append((language, name)) + + return out + +def hablar(texto): + speak(texto, voice = voice.defaultVoice().name) + + +if __name__ == "__main__": + hablar("hola") \ No newline at end of file diff --git a/speak/new_main.py b/speak/new_main.py new file mode 100644 index 0000000..f46cac7 --- /dev/null +++ b/speak/new_main.py @@ -0,0 +1,15 @@ +#! /usr/bin/python + +# To change this template, choose Tools | Templates +# and open the template in the editor. + +import urllib2 + +def internet_on(): + try: + response=urllib2.urlopen('http://74.125.113.99',timeout=1) + return True + except urllib2.URLError as err: pass + return False + +print internet_on() \ No newline at end of file diff --git a/speak/voice.py b/speak/voice.py new file mode 100644 index 0000000..0cf2b8d --- /dev/null +++ b/speak/voice.py @@ -0,0 +1,169 @@ +# Adapted from the activity Speak http://activities.sugarlabs.org/es-ES/sugar/addon/4038 +# Copyright (C) 2008 Joshua Minor +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import re +import os +from gettext import gettext as _ + +import espeak_cmd as espeak + +import logging +logger = logging.getLogger('speak') + + + +# Lets trick gettext into generating entries +# for the voice names we expect espeak to have +# If espeak actually has new or different names +# then they won't get translated, but they +# should still show up in the interface. +expectedVoiceNames = [ + _("Brazil"), + _("Swedish"), + _("Icelandic"), + _("Romanian"), + _("Swahili"), + _("Hindi"), + _("Dutch"), + _("Latin"), + _("Hungarian"), + _("Macedonian"), + _("Welsh"), + _("French"), + _("Norwegian"), + _("Russian"), + _("Afrikaans"), + _("Finnish"), + _("Default"), + _("Cantonese"), + _("Scottish"), + _("Greek"), + _("Vietnam"), + _("English"), + _("Lancashire"), + _("Italian"), + _("Portugal"), + _("German"), + _("Whisper"), + _("Croatian"), + _("Czech"), + _("Slovak"), + _("Spanish"), + _("Polish"), + _("Esperanto") +] + +_allVoices = {} +_defaultVoice = None + + +class Voice: + def __init__(self, language, name): + self.language = language + self.name = name + friendlyname = name + friendlyname = friendlyname.replace('-test', '') + friendlyname = friendlyname.replace('_test', '') + friendlyname = friendlyname.replace('en-', '') + friendlyname = friendlyname.replace('english-wisper', 'whisper') + friendlyname = friendlyname.replace('english-us', 'us') + + friendlynameRP = name # friendlyname for RP + friendlynameRP = friendlynameRP.replace('english_rp', 'rp') + friendlynameRP = friendlynameRP.replace('english_wmids', 'wmids') + + parts = re.split('[ _-]', friendlyname) + partsRP = re.split('[ _]', friendlynameRP) # RE for english_RP + self.short_name = _(parts[0].capitalize()) + self.friendlyname = ' '.join([self.short_name] + parts[1:]) + + friendlynameRP1 = None + if friendlynameRP == 'rp': + + friendlynameRP1 = 'English (Received Pronunciation)' + self.friendlyname = 'English (Received Pronunciation)' + + friendlynameUS = None + if friendlyname == 'us': + friendlynameUS = 'English (USA)' + self.friendlyname = 'English (USA)' + + friendlynameWMIDS = None + if friendlynameRP == 'wmids': + friendlynameWMIDS = 'English (West Midlands)' + self.friendlyname = 'English (West Midlands)' + + def __cmp__(self, other): + return cmp(self.friendlyname, other.friendlyname if other else '') + + +def allVoices(): + if _allVoices: + return _allVoices + + for language, name in espeak.voices(): + voice = Voice(language, name) + _allVoices[voice.friendlyname] = voice + + return _allVoices + + +def by_name(name): + return allVoices().get(name, defaultVoice()) + + +def defaultVoice(): + """Try to figure out the default voice, from the current locale ($LANG). + Fall back to espeak's voice called Default.""" + + global _defaultVoice + + if _defaultVoice: + return _defaultVoice + + voices = allVoices() + + def fit(a, b): + "Compare two language ids to see if they are similar." + as_ = re.split(r'[^a-z]+', a.lower()) + bs = re.split(r'[^a-z]+', b.lower()) + for count in range(0, min(len(as_), len(bs))): + if as_[count] != bs[count]: + count -= 1 + break + return count + try: + lang = os.environ["LANG"] + except: + lang = "" + + best = voices[_("Default")] + for voice in voices.values(): + voiceMetric = fit(voice.language, lang) + bestMetric = fit(best.language, lang) + if lang == 'en_AU.UTF-8': + if voice.friendlyname == 'English (Received Pronunciation)': + best = voice + break + if voiceMetric > bestMetric: + best = voice + + print "Best voice for LANG %s seems to be %s %s" % (lang, + best.language, + best.friendlyname) + _defaultVoice = best + return best diff --git a/threads/TInterpreterPlaySound.py b/threads/TInterpreterPlaySound.py new file mode 100644 index 0000000..f3edf58 --- /dev/null +++ b/threads/TInterpreterPlaySound.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +import os +if os.name != "nt": + import pygst + pygst.require("0.10") + import gst + +import threading +import os + +class TInterpreterPlaySound (threading.Thread): + player = None + def __init__(self, sounds): + super(TInterpreterPlaySound, self).__init__() + self.sounds = [] + for s in sounds: + self.sounds.append("file://" + os.path.abspath(s)) + + if TInterpreterPlaySound.player == None: + TInterpreterPlaySound.player = gst.element_factory_make("playbin", "player") + + bus = TInterpreterPlaySound.player.get_bus() + bus.add_signal_watch() + bus.connect("message", self.onMessage) + + def onMessage(self, bus, message): + t = message.type + if t == gst.MESSAGE_EOS: + self.player.set_state(gst.STATE_NULL) + elif t == gst.MESSAGE_ERROR: + self.player.set_state(gst.STATE_NULL) + err, debug = message.parse_error() + print "Error: %s" % err, debug + + + def run (self): + #set the uri + print self.sounds[0] + TInterpreterPlaySound.player.set_property('uri', self.sounds[0]) + #start playing + TInterpreterPlaySound.player.set_state(gst.STATE_PLAYING) + +# #listen for tags on the message bus; tag event might be called more than once +# bus = player.get_bus() +# bus.enable_sync_message_emission() +# bus.add_signal_watch() +# bus.connect('message::tag', on_tag) diff --git a/threads/__init__.py b/threads/__init__.py new file mode 100644 index 0000000..dbaa255 --- /dev/null +++ b/threads/__init__.py @@ -0,0 +1,2 @@ +__author__="rodripf" +__date__ ="$24/09/2012 11:56:25 AM$" \ No newline at end of file diff --git a/util/About.py b/util/About.py new file mode 100644 index 0000000..122067b --- /dev/null +++ b/util/About.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import gtk + +class About: + + + def show(self): + #base this on a message dialog + dialog = gtk.MessageDialog( + None, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, + gtk.MESSAGE_QUESTION, + gtk.BUTTONS_OK, + None) + dialog.set_markup("TIXO\n\nDepartamento de Ingenieria - rodripf\nFundacion Teleton - 2011") + + dialog.show_all() + #go go go + dialog.run() + dialog.destroy() + + + +if __name__ == '__main__': + d = About() + print d.show() + gtk.main() diff --git a/util/About.py~ b/util/About.py~ new file mode 100644 index 0000000..78d47b8 --- /dev/null +++ b/util/About.py~ @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import gtk + +class About: + + + def show(self): + #base this on a message dialog + dialog = gtk.MessageDialog( + None, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, + gtk.MESSAGE_QUESTION, + gtk.BUTTONS_OK, + None) + dialog.set_markup("Mateton\n\nDepartamento de Ingenieria - rodripf\nFundacion Teleton - 2011") + + dialog.show_all() + #go go go + dialog.run() + dialog.destroy() + + + +if __name__ == '__main__': + d = About() + print d.show() + gtk.main() \ No newline at end of file diff --git a/util/ChooseProject.py b/util/ChooseProject.py new file mode 100644 index 0000000..20469b5 --- /dev/null +++ b/util/ChooseProject.py @@ -0,0 +1,116 @@ +import os.path +# -*- coding: utf-8 -*- +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +__author__ = "rodripf" +__date__ = "$01/02/2012 10:45:52 AM$" + +import os +import pygtk +pygtk.require('2.0') +import gtk +import string + +class ChooseProject: + def limpiarNombres(self, text): + tmp = string.replace(text, "_", " ") + return string.replace(tmp, ".jpg", "") + + def __init__(self, dir): + self.onAbrir = [] + # Create a new window + self.window = gtk.Dialog("Abrir") + + self.window.set_size_request(400, 500) + + self.window.connect("delete_event", self.deleteEvent) + self.window.set_position(gtk.WIN_POS_CENTER) + + self.treestore = gtk.TreeStore(str, str) + + #dir = "./" + car = os.listdir(dir) + print car + for e in car: + if(os.path.isdir(os.path.join(dir, e))): + self.treestore.append(None, [e,e]) + + + self.treeview = gtk.TreeView(self.treestore) + self.tvcolumn = gtk.TreeViewColumn() + self.treeview.append_column(self.tvcolumn) + self.cell = gtk.CellRendererText() + self.tvcolumn.pack_start(self.cell, True) + + # set the cell "text" attribute to column 0 - retrieve text + # from that column in treestore + self.tvcolumn.add_attribute(self.cell, 'text', 0) + + # make it searchable + self.treeview.set_search_column(0) + + # Allow sorting on the column + self.tvcolumn.set_sort_column_id(0) + + self.window.vbox.add(self.treeview) + + abrir = gtk.Button("Abrir") + abrir.connect("clicked", self.abrirCB) + self.window.action_area.pack_start(abrir, True, True, 0) + + + cancelar = gtk.Button("Cancelar") + cancelar.connect("clicked", self.cancelarCB) + self.window.action_area.pack_start(cancelar, True, True, 0) + + def addOnAbrirListener(self, action): + self.onAbrir.append(action) + + def show(self): + self.window.show_all() + + def abrirCB(self, b): + treeselection = self.treeview.get_selection() + treeselection.set_mode(gtk.SELECTION_SINGLE) + (model, iter) = treeselection.get_selected() + + d = self.treestore.get_value(iter, 1) + + self.window.destroy() + for f in self.onAbrir: + f(d) + + return d + + + def cancelarCB(self, b): + self.window.destroy() + + def deleteEvent(self, widget, event, data=None): + self.window.destroy() +def main(): + gtk.main() + +if __name__ == "__main__": + tvexample = ChooseProject("../proyectos") + tvexample.show() + main() + \ No newline at end of file diff --git a/util/ControlFactory.py b/util/ControlFactory.py new file mode 100644 index 0000000..8818925 --- /dev/null +++ b/util/ControlFactory.py @@ -0,0 +1,82 @@ +##########################Control Factory######################################## +# Control Factory extracted from Abacus, an activity by Walter Bender published # +# under the GNU General Public License v3 # +# Copyright (c) 2010-11, Walter Bender # +# http://activities.sugarlabs.org/es-ES/sugar/addon/4293 # +################################################################################# + +import gtk +from sugar.graphics.toolbutton import ToolButton + +def buttonFactory(icon_name, toolbar, callback, cb_arg=None, tooltip=None, + accelerator=None): + '''Factory for making toolbar buttons''' + button = ToolButton(icon_name) + if tooltip is not None: + button.set_tooltip(tooltip) + button.props.sensitive = True + if accelerator is not None: + button.props.accelerator = accelerator + if cb_arg is None: + button.connect('clicked', callback) + else: + button.connect('clicked', cb_arg) + if hasattr(toolbar, 'insert'): # the main toolbar + toolbar.insert(button, -1) + else: # or a secondary toolbar + toolbar.props.page.insert(button, -1) + button.show() + return button + + +def radioFactory(icon_name, toolbar, callback, cb_arg=None, + tooltip=None, group=None): + ''' Add a radio button to a toolbar ''' + button = RadioToolButton(group=group) + button.set_named_icon(icon_name) + if tooltip is not None: + button.set_tooltip(tooltip) + if cb_arg is None: + button.connect('clicked', callback) + else: + button.connect('clicked', callback, cb_arg) + if hasattr(toolbar, 'insert'): # the main toolbar + toolbar.insert(button, -1) + else: # or a secondary toolbar + toolbar.props.page.insert(button, -1) + button.show() + return button + + +def labelFactory(label_text, toolbar): + ''' Factory for adding a label to a toolbar ''' + label = gtk.Label(label_text) + label.set_line_wrap(True) + label.show() + toolitem = gtk.ToolItem() + toolitem.add(label) + toolbar.insert(toolitem, -1) + toolitem.show() + return label + + +def spinFactory(default, min, max, callback, toolbar): + spin_adj = gtk.Adjustment(default, min, max, 1, 32, 0) + spin = gtk.SpinButton(spin_adj, 0, 0) + spin_id = spin.connect('value-changed', callback) + spin.set_numeric(True) + spin.show() + toolitem = gtk.ToolItem() + toolitem.add(spin) + toolbar.insert(toolitem, -1) + toolitem.show() + return spin + + +def separatorFactory(toolbar, expand=False, visible=True): + ''' add a separator to a toolbar ''' + separator = gtk.SeparatorToolItem() + separator.props.draw = visible + separator.set_expand(expand) + toolbar.insert(separator, -1) + separator.show() \ No newline at end of file diff --git a/util/OpenNewProject.py b/util/OpenNewProject.py new file mode 100644 index 0000000..c80bb1c --- /dev/null +++ b/util/OpenNewProject.py @@ -0,0 +1,54 @@ +import os +# Tixo - A Sugar interpreter for TICO projects +# Copyright (C) 2012 Rodrigo Perez Fulloni +# Fundacion Teleton Uruguay - Departamento de Ingenieria +# +# Based on TICO Project: http://www.proyectotico.com/ +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +__author__="Rodrigo" +__date__ ="$27-sep-2012 12:59:02$" + + +from zipfile import * +import os.path + + +class OpenNewProject: + PROYECTOS = "proyectos" + + def __init__(self, file, proyName): + proyName = os.path.splitext(proyName)[0] + destFolder = os.path.join(self.PROYECTOS, proyName) + if os.path.exists(destFolder): + raise Exception("El proyecto ya existe.") + else: + if is_zipfile(file): + os.makedirs(destFolder) + zip = ZipFile(file, 'r') + zip.extractall(destFolder) + self.carpeta = proyName + else: + raise Exception("El archivo no es valido o esta corrupto.") + + def getProjectName(self): + return self.carpeta + +if __name__ == "__main__": + try: + o = OpenNewProject("pruebaControl.tco", "pruebaControl") + except Exception as ex: + print ex diff --git a/util/Singleton.py b/util/Singleton.py new file mode 100644 index 0000000..c161866 --- /dev/null +++ b/util/Singleton.py @@ -0,0 +1,16 @@ +class Singleton(object): + _instance = None + def __new__(cls, * args, ** kwargs): + if not cls._instance: + cls._instance = super(Singleton, cls).__new__( + cls, * args, ** kwargs) + return cls._instance + + +if __name__ == '__main__': + s1 = Singleton() + s2 = Singleton() + if s1 == s2: + print "Same" + else: + print "Different" \ No newline at end of file diff --git a/util/__init__.py b/util/__init__.py new file mode 100644 index 0000000..102ba58 --- /dev/null +++ b/util/__init__.py @@ -0,0 +1,2 @@ +__author__="Rodrigo" +__date__ ="$27-sep-2012 12:58:29$" \ No newline at end of file -- cgit v0.9.1