diff options
Diffstat (limited to 'activity.py')
-rw-r--r-- | activity.py | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/activity.py b/activity.py index 16e7b46..7e15a1a 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) @@ -83,11 +86,17 @@ class AudioPatternActivity(activity.Activity): cancelarButton = gtk.Button() cancelarButton.set_label('CANCELAR') + cancelarButton.connect('focus-in-event', self.__say_text) cabeceraHbox.pack_start(cancelarButton, fill=False) cancelarButton.connect('clicked', self.__button_clicked_cb, 'CANCELAR') cuerpoHbox = gtk.HBox(False, 20) cancelarButton.set_size_request(150, 50) + 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() @@ -99,6 +108,10 @@ class AudioPatternActivity(activity.Activity): seleccionadosTable.set_size_request(200, 400) #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() @@ -110,7 +123,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) @@ -178,9 +220,19 @@ class AudioPatternActivity(activity.Activity): def __on_key_press_event(self, widget, event): keyname = gtk.gdk.keyval_name(event.keyval) - print "Key %s (%d) was pressed" % (keyname, event.keyval) - if keyname == 'space': - print "Dentro del IF" - widget_focus = widget.get_focus - #print widget_focus.get_tab_label + #print "Key %s (%d) was pressed" % (keyname, event.keyval) + # if keyname == 'Left' or keyname == 'Right' or keyname == 'Up' or keyname == 'Down': + # widget_focus = widget.get_focus() + # logging.debug(widget_focus.get_label()) + + def __on_enter_event(self, widget, event): + widget_focus = widget.get_focus() + logging.debug(widget_focus.get_label()) + def __say_text(self, widget, event): + label = widget.get_label() + logging.debug(label) + self.say(label) + + def say(self, text): + Popen(['espeak', '-v', 'es', text]) |