Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
Diffstat (limited to 'activity.py')
-rw-r--r--activity.py117
1 files changed, 78 insertions, 39 deletions
diff --git a/activity.py b/activity.py
index a21938d..ff46269 100644
--- a/activity.py
+++ b/activity.py
@@ -1,3 +1,6 @@
+#!/usr/bin/python
+# -*- encoding: utf-8 -*-
+
# Copyright 2013 Patricia Espinola y Victor Cubas
#
# This program is free software; you can redistribute it and/or modify
@@ -18,6 +21,8 @@
import gtk
import logging
+import voice
+import programa
from gettext import gettext as _
@@ -29,6 +34,11 @@ from sugar.activity.widgets import TitleEntry
from sugar.activity.widgets import StopButton
from sugar.activity.widgets import ShareButton
+label_opciones = ["Claro - Oscuro", "Joven - Anciano", "Gordo - Flaco", "Alto - Bajo", "Pequeño - Grande", "Feliz - Triste"]
+listImagenes = ['gordo.jpg', 'flaco.jpg','alto.jpg', 'bajo.jpg']
+correct_option = [label_opciones[2], "Alto - Bajo"]
+
+
class PiensaEscribeActivity(activity.Activity):
"""PiensaEscribe class as specified in activity.info"""
@@ -73,54 +83,83 @@ class PiensaEscribeActivity(activity.Activity):
# label with the text, make the string translatable
def createGUI(self):
-
- correct_option = [3, 2]
- #fila_option = 0
- #cantidad_imagenes = 2
- image_number = 0
+ self.indice_opciones = 0
+ self.indice_imagen = 0
+ self.indice_resp_correcta = 0
vbox = gtk.VBox()
hbox = gtk.HBox()
- imagen1 = gtk.Image()
- imagen1.set_from_file('gordo.jpg')
- imagen2 = gtk.Image()
- imagen2.set_from_file('flaco.jpg')
-
- button1 = gtk.Button()
- button1.set_label('Claro - Oscuro')
- button2 = gtk.Button()
- button2.set_label('Joven - Anciano')
- button3 = gtk.Button()
- button3.set_label('Gordo - Flaco')
-
- button1.connect('enter', self.__sobre_boton_cb)
- button2.connect('enter', self.__sobre_boton_cb)
- button3.connect('enter', self.__sobre_boton_cb)
- button1.connect('clicked', self.__correcto_cb, correct_option[0], 1)
- button2.connect('clicked', self.__correcto_cb, correct_option[0], 2)
- button3.connect('clicked', self.__correcto_cb, correct_option[0], 3)
-
- hbox.add(imagen1)
- hbox.add(imagen2)
+ #window.set_default_size(100,100)
vbox.add(hbox)
- vbox.add(button1)
- vbox.add(button2)
- vbox.add(button3)
-
+
+ imagen1 = gtk.Image()
+ imagen2 = gtk.Image()
+ button1 = gtk.Button()
+ button2 = gtk.Button()
+ button3 = gtk.Button()
+
+ imagen1.set_from_file(listImagenes[self.indice_imagen])
+ self.indice_imagen += 1
+ imagen2.set_from_file(listImagenes[self.indice_imagen])
+ self.indice_imagen += 1
+
+ button1.set_label(label_opciones[self.indice_opciones])
+ self.indice_opciones += 1
+ button2.set_label(label_opciones[self.indice_opciones])
+ self.indice_opciones += 1
+ button3.set_label(label_opciones[self.indice_opciones])
+ self.indice_opciones += 1
+
+ button1.connect('enter', self.__sobre_boton_cb)
+ button2.connect('enter', self.__sobre_boton_cb)
+ button3.connect('enter', self.__sobre_boton_cb)
+ button1.connect('clicked', self.__correcto_cb, correct_option[self.indice_resp_correcta], imagen1,
+ imagen2, button1, button2, button3)
+ button2.connect('clicked', self.__correcto_cb, correct_option[self.indice_resp_correcta], imagen1,
+ imagen2, button1, button2, button3)
+ button3.connect('clicked', self.__correcto_cb, correct_option[self.indice_resp_correcta], imagen1,
+ imagen2, button1, button2, button3)
+
+
+ hbox.add(imagen1)
+ hbox.add(imagen2)
+ vbox.add(button1)
+ vbox.add(button2)
+ vbox.add(button3)
+
self.set_canvas(vbox)
vbox.show_all()
+ def resetear(self, imagen1, imagen2, button1, button2, button3):
+ imagen1.set_from_file(listImagenes[self.indice_imagen])
+ self.indice_imagen += 1
+ imagen2.set_from_file(listImagenes[self.indice_imagen])
+ self.indice_imagen += 1
+
+ button1.set_label(label_opciones[self.indice_opciones])
+ self.indice_opciones += 1
+ button2.set_label(label_opciones[self.indice_opciones])
+ self.indice_opciones += 1
+ button3.set_label(label_opciones[self.indice_opciones])
+ self.indice_opciones += 1
+ print self.indice_resp_correcta
+ self.indice_resp_correcta += 1
+ print self.indice_resp_correcta
+
+ def __correcto_cb(self, button, clave, imagen1, imagen2, button1, button2, button3):
+ if button.get_label() == clave:
+ #print clave
+ voice.say('Opcion correcta')
+ #self.indice_resp_correcta += 1
+ self.resetear(imagen1, imagen2, button1, button2, button3)
+ print self.indice_resp_correcta
+ else:
+ print clave
+ voice.say('Opcion incorrecta')
- def __correcto_cb(self, button, correct_option, clave):
- if correct_option == clave:
- voice.say('opcion - correcta')
- else:
- voice.say('opcion - incorrecta')
-
+
def __sobre_boton_cb(self, button):
voice.say(button.get_label())
+
-if __name__ == "__main__":
- my_app = PiensaEscribeActivity()
- gtk.main()