From 5d4cc12f1ae017ef5cebaa668a1d5ca36f64dad0 Mon Sep 17 00:00:00 2001 From: mbvierci Date: Thu, 24 Jan 2013 20:00:39 +0000 Subject: Parser en el label de los botones y voz --- diff --git a/activity.py b/activity.py index 7977c2f..30a7e11 100644 --- a/activity.py +++ b/activity.py @@ -26,6 +26,8 @@ from sugar.activity.widgets import ActivityToolbox from sugar.activity.widgets import TitleEntry from sugar.activity.widgets import StopButton from sugar.activity.widgets import ShareButton +from ConfigParser import SafeConfigParser +from subprocess import Popen class AudioPatternActivity(activity.Activity): @@ -69,6 +71,7 @@ class AudioPatternActivity(activity.Activity): jugarButton = gtk.Button() principalVbox.pack_start(cabeceraHbox, fill=False) jugarButton.set_label('JUGAR') + jugarButton.connect('focus-in-event', self.__say_text) cabeceraHbox.pack_start(jugarButton, fill=False) jugarButton.set_size_request(150, 50) @@ -89,12 +92,19 @@ class AudioPatternActivity(activity.Activity): self.connect('key-press-event', self.__on_key_press_event) + parser = SafeConfigParser() + parser.read('config.ini') + seleccionadosTable = gtk.Table(4, 1, True) seleccionadoUnoButton = gtk.Button() seleccionadoDosButton = gtk.Button() seleccionadoTresButton = gtk.Button() #resultadoButton = gtk.Button() + seleccionadoUnoButton.connect('focus-in-event', self.__say_text) + seleccionadoDosButton.connect('focus-in-event', self.__say_text) + seleccionadoTresButton.connect('focus-in-event', self.__say_text) + opcionesTable = gtk.Table(3,3, True) opcionUno = gtk.Button() opcionDos = gtk.Button() @@ -105,7 +115,36 @@ class AudioPatternActivity(activity.Activity): opcionSiete = gtk.Button() opcionOcho = gtk.Button() opcionNueve = gtk.Button() - + + opcionUno.connect('focus-in-event', self.__say_text) + opcionDos.connect('focus-in-event', self.__say_text) + opcionTres.connect('focus-in-event', self.__say_text) + opcionCuatro.connect('focus-in-event', self.__say_text) + opcionCinco.connect('focus-in-event', self.__say_text) + opcionSeis.connect('focus-in-event', self.__say_text) + opcionSiete.connect('focus-in-event', self.__say_text) + opcionOcho.connect('focus-in-event', self.__say_text) + opcionNueve.connect('focus-in-event', self.__say_text) + + uno = parser.get('cantidad', 'tres') + ' ' + parser.get('elemento', 'leones') + ' de ' + parser.get('material', 'metal') + opcionUno.set_label(uno) + dos = parser.get('cantidad', 'cuatro') + ' ' + parser.get('elemento', 'jirafas') + ' de ' + parser.get('material', 'madera') + opcionDos.set_label(dos) + tres = parser.get('cantidad', 'cinco') + ' ' + parser.get('elemento', 'monos') + ' de ' + parser.get('material', 'vidrio') + opcionTres.set_label(tres) + cuatro = parser.get('cantidad', 'cuatro') + ' ' + parser.get('elemento', 'leones') + ' de ' + parser.get('material', 'madera') + opcionCuatro.set_label(cuatro) + cinco = parser.get('cantidad', 'cinco') + ' ' + parser.get('elemento', 'jirafas') + ' de ' + parser.get('material', 'metal') + opcionCinco.set_label(cinco) + seis = parser.get('cantidad', 'tres') + ' ' + parser.get('elemento', 'monos') + ' de ' + parser.get('material', 'vidrio') + opcionSeis.set_label(seis) + siete = parser.get('cantidad', 'tres') + ' ' + parser.get('elemento', 'leones') + ' de ' + parser.get('material', 'madera') + opcionSiete.set_label(siete) + ocho = parser.get('cantidad', 'cuatro') + ' ' + parser.get('elemento', 'monos') + ' de ' + parser.get('material', 'metal') + opcionOcho.set_label(ocho) + nueve = parser.get('cantidad', 'cinco') + ' ' + parser.get('elemento', 'leones') + ' de ' + parser.get('material', 'vidrio') + opcionNueve.set_label(nueve) + self.set_canvas(principalVbox) #window.add(principalVbox) principalVbox.add(cabeceraHbox) @@ -153,4 +192,9 @@ class AudioPatternActivity(activity.Activity): logging.debug(widget_focus.get_label()) def __say_text(self, widget, event): - logging.debug("djfhsdjfhsdkjfhsjkdfh") + label = widget.get_label() + logging.debug(label) + self.say(label) + + def say(self, text): + Popen(['espeak', '-v', 'es', text]) diff --git a/activity.pyc b/activity.pyc index 410997c..91412f3 100644 --- a/activity.pyc +++ b/activity.pyc Binary files differ diff --git a/activity.py~ b/activity.py~ index 7977c2f..7e8e2d1 100644 --- a/activity.py~ +++ b/activity.py~ @@ -26,6 +26,7 @@ from sugar.activity.widgets import ActivityToolbox from sugar.activity.widgets import TitleEntry from sugar.activity.widgets import StopButton from sugar.activity.widgets import ShareButton +from ConfigParser import SafeConfigParser class AudioPatternActivity(activity.Activity): @@ -69,6 +70,7 @@ class AudioPatternActivity(activity.Activity): jugarButton = gtk.Button() principalVbox.pack_start(cabeceraHbox, fill=False) jugarButton.set_label('JUGAR') + jugarButton.connect('focus-in-event', self.__say_text) cabeceraHbox.pack_start(jugarButton, fill=False) jugarButton.set_size_request(150, 50) @@ -89,12 +91,19 @@ class AudioPatternActivity(activity.Activity): self.connect('key-press-event', self.__on_key_press_event) + parser = SafeConfigParser() + parser.read('config.ini') + seleccionadosTable = gtk.Table(4, 1, True) seleccionadoUnoButton = gtk.Button() seleccionadoDosButton = gtk.Button() seleccionadoTresButton = gtk.Button() #resultadoButton = gtk.Button() + seleccionadoUnoButton.connect('focus-in-event', self.__say_text) + seleccionadoDosButton.connect('focus-in-event', self.__say_text) + seleccionadoTresButton.connect('focus-in-event', self.__say_text) + opcionesTable = gtk.Table(3,3, True) opcionUno = gtk.Button() opcionDos = gtk.Button() @@ -105,7 +114,36 @@ class AudioPatternActivity(activity.Activity): opcionSiete = gtk.Button() opcionOcho = gtk.Button() opcionNueve = gtk.Button() - + + opcionUno.connect('focus-in-event', self.__say_text) + opcionDos.connect('focus-in-event', self.__say_text) + opcionTres.connect('focus-in-event', self.__say_text) + opcionCuatro.connect('focus-in-event', self.__say_text) + opcionCinco.connect('focus-in-event', self.__say_text) + opcionSeis.connect('focus-in-event', self.__say_text) + opcionSiete.connect('focus-in-event', self.__say_text) + opcionOcho.connect('focus-in-event', self.__say_text) + opcionNueve.connect('focus-in-event', self.__say_text) + + uno = parser.get('cantidad', 'tres') + ' ' + parser.get('elemento', 'leones') + ' de ' + parser.get('material', 'metal') + opcionUno.set_label(uno) + dos = parser.get('cantidad', 'cuatro') + ' ' + parser.get('elemento', 'jirafas') + ' de ' + parser.get('material', 'madera') + opcionDos.set_label(dos) + tres = parser.get('cantidad', 'cinco') + ' ' + parser.get('elemento', 'monos') + ' de ' + parser.get('material', 'vidrio') + opcionTres.set_label(tres) + cuatro = parser.get('cantidad', 'cuatro') + ' ' + parser.get('elemento', 'leones') + ' de ' + parser.get('material', 'madera') + opcionCuatro.set_label(cuatro) + cinco = parser.get('cantidad', 'cinco') + ' ' + parser.get('elemento', 'jirafas') + ' de ' + parser.get('material', 'metal') + opcionCinco.set_label(cinco) + seis = parser.get('cantidad', 'tres') + ' ' + parser.get('elemento', 'monos') + ' de ' + parser.get('material', 'vidrio') + opcionSeis.set_label(seis) + siete = parser.get('cantidad', 'tres') + ' ' + parser.get('elemento', 'leones') + ' de ' + parser.get('material', 'madera') + opcionSiete.set_label(siete) + ocho = parser.get('cantidad', 'cuatro') + ' ' + parser.get('elemento', 'monos') + ' de ' + parser.get('material', 'metal') + opcionOcho.set_label(ocho) + nueve = parser.get('cantidad', 'cinco') + ' ' + parser.get('elemento', 'leones') + ' de ' + parser.get('material', 'vidrio') + opcionNueve.set_label(nueve) + self.set_canvas(principalVbox) #window.add(principalVbox) principalVbox.add(cabeceraHbox) @@ -153,4 +191,9 @@ class AudioPatternActivity(activity.Activity): logging.debug(widget_focus.get_label()) def __say_text(self, widget, event): - logging.debug("djfhsdjfhsdkjfhsjkdfh") + label = widget.get_label() + logging.debug(label) + self.say(label) + + def say(self, text): + Popen(['espeak', '-v', 'es', text]) diff --git a/config.ini b/config.ini index 820e711..8792440 100644 --- a/config.ini +++ b/config.ini @@ -1,9 +1,15 @@ [elemento] leones = leones +jirafas = jirafas +monos = monos [cantidad] tres = 3 +cuatro = 4 +cinco = 5 [material] metal = metal +madera = madera +vidrio = vidrio diff --git a/config.ini~ b/config.ini~ new file mode 100644 index 0000000..820e711 --- /dev/null +++ b/config.ini~ @@ -0,0 +1,9 @@ +[elemento] +leones = leones + +[cantidad] +tres = 3 + +[material] +metal = metal + -- cgit v0.9.1