Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpamarilla <pj.amarilla@gmail.com>2013-01-27 17:35:20 (GMT)
committer pamarilla <pj.amarilla@gmail.com>2013-01-27 17:35:20 (GMT)
commitaa64b447c6ab864eaa20786611276d6d3f4e43e2 (patch)
tree4e38ba682da7801f4fb22b6aa9e939d0c794a5b5
parentcf5cc8fe58de804a2654d0dc066369b41d4f2bc3 (diff)
barrido automatico y usando el sintetizador, pero sin sugarizar
-rw-r--r--config.ini64
-rw-r--r--expresar.py118
-rw-r--r--parser.py20
3 files changed, 187 insertions, 15 deletions
diff --git a/config.ini b/config.ini
index 0fee239..5868247 100644
--- a/config.ini
+++ b/config.ini
@@ -1,12 +1,68 @@
#Expresar
[initialize]
-items = 2
+items = 5
[seccion0]
name = comer
-info = Quiero comer!
+info = Tengo Hambre
[seccion1]
-name = comer
-info = Quiero beber!
+name = beber
+info = Tengo sed
+
+[seccion2]
+name = banho
+info = Quiero ir al banho
+
+[seccion3]
+name = dormir
+info = Tengo suenho
+
+[seccion4]
+name = jugar
+info = Quiero jugar
+
+[seccion5]
+name = cansado
+info = Estoy cansado
+
+[seccion6]
+name = enfermo
+info = Me siento enfermo
+
+[seccion7]
+name = gracias
+info = Gracias
+
+[seccion8]
+name = por favor
+info = Por favor
+
+[seccion9]
+name = panza
+info = Me duele la panza
+
+[seccion10]
+name = Si
+info = Si
+
+[seccion11]
+name = No
+info = No
+
+[seccion12]
+name = pasear
+info = Vamos de paseo
+
+[seccion13]
+name = sugar
+info = Me gusta Sugar
+
+[seccion14]
+name = musica
+info = Quiero escuchar musica
+
+[seccion15]
+name = television
+info = Quiero ver la tele
diff --git a/expresar.py b/expresar.py
new file mode 100644
index 0000000..7ddb119
--- /dev/null
+++ b/expresar.py
@@ -0,0 +1,118 @@
+import gtk
+import gobject
+import math
+
+from parser import parser
+from sintetizar import sintetizar
+
+DELAY = 1300
+LENGHT = 4
+
+class MyGUI:
+
+ def __init__( self, title):
+ self.window = gtk.Window()
+ self.title = title
+ self.window.set_title(title)
+
+ self._pressButton_counter = 0
+ self.window.set_size_request( 260, -1)
+ self.window.connect("destroy", self.destroy)
+
+ self.listaSecciones = []
+ parser(self.listaSecciones)
+ print self.listaSecciones[1]
+ self.lenghtSecciones = int(math.sqrt(len(self.listaSecciones)))
+
+ self.hbox = gtk.HBox()
+
+ self.table = gtk.Table(LENGHT, LENGHT, True)
+ self.indiceSecciones = 0
+ self.create_interior(self.table, self.listaSecciones)
+
+ self.window.add(self.hbox)
+ self.window.show_all()
+ self._button_index = 0
+ self._button_index_2 = 0
+ self._indice = 0
+ self._button_list = []
+ gobject.timeout_add(DELAY, self.__timeout_cb, self.table)
+
+ def create_interior( self, table, listaSecciones):
+ self.hbox.add(table)
+ inicio_left = 0
+ fin_right = 1
+ inicio_top = 0
+ fin_bottom = 1
+ for colu in range(LENGHT):
+ for fila in range(LENGHT):
+ boton = gtk.Button(str(fila)+"-"+str(colu))
+ boton.connect('key-press-event', self.__pressButton_count)
+ table.attach(boton, inicio_left, fin_right, inicio_top, fin_bottom)
+ boton.show()
+ inicio_top = inicio_top + 1
+ fin_bottom = fin_bottom + 1
+
+ inicio_top = 0
+ fin_bottom = 1
+ inicio_left = inicio_left + 1
+ fin_right = fin_right + 1
+
+ #self.table.attach(child, left_attach, right_attach, top_attach, bottom_attach)
+ table.show()
+
+ def __timeout_cb(self, table):
+
+ buttons = table.get_children()
+ buttons.reverse()
+
+ if (self._pressButton_counter == 1):
+ self._button_index_2 = (self._button_index_2 + 1) % len(self._button_list)
+ self._button_list[self._button_index_2].grab_focus()
+ self._button_list[self._button_index_2].modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('red'))
+ self._button_list[self._button_index_2 - 1].modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('green'))
+ elif (self._pressButton_counter == 0):
+ self._button_index = (self._button_index) % len(buttons)
+
+ self._button_list = buttons[self._button_index:self._button_index+LENGHT]
+
+ for i in self._button_list:
+ i.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('green'))
+
+ for cero in range(self._button_index):
+ buttons[cero].modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('gray'))
+
+ self._button_index = self._button_index + LENGHT
+
+ indice = self._button_index
+ while indice < len(buttons):
+ buttons[indice].modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('gray'))
+ indice = indice + 1
+
+ else:
+ self._pressButton_counter = 0
+ self.__newWindow(self._button_list[self._button_index_2], self._button_list[self._button_index_2].get_label())
+
+ return True
+
+ def __pressButton_count(self, table, arg):
+ self._pressButton_counter = self._pressButton_counter + 1
+
+ def __newWindow(self, button, button_label):
+ #self.hbox.remove(self.table)
+ #label = gtk.Label()
+ #label.set_text(button_label)
+ #self.hbox.add(label)
+ #label.show()
+ #self.hbox.show()
+ sintetizar(button_label)
+
+ def main( self):
+ gtk.main()
+
+ def destroy(self, w):
+ gtk.main_quit()
+
+if __name__ == "__main__":
+ m = MyGUI( "Table example")
+ m.main()
diff --git a/parser.py b/parser.py
index d18b2e1..13746af 100644
--- a/parser.py
+++ b/parser.py
@@ -1,22 +1,20 @@
from ConfigParser import SafeConfigParser
-def parser():
+def parser(listaSecciones):
parser = SafeConfigParser()
parser.read('config.ini')
nro_items = parser.getint('initialize','items')
etiqueta = 'seccion'
- list = []
+ #listaSecciones = []
for i in range(nro_items):
-
-
- etiqueta = etiqueta + str(i)
- print parser.get(etiqueta, 'info')
- list_seccion=[]
- list_seccion.insert(0, parser.get(etiqueta, 'name'))
- list_seccion.insert(1, parser.get(etiqueta, 'info'))
- list.insert(i,list_seccion)
- etiqueta = 'seccion'
+ etiqueta = etiqueta + str(i)
+ #print parser.get(etiqueta, 'info')
+ list_seccion=[]
+ list_seccion.insert(0, parser.get(etiqueta, 'name'))
+ list_seccion.insert(1, parser.get(etiqueta, 'info'))
+ listaSecciones.insert(i,list_seccion)
+ etiqueta = 'seccion'