Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsamurey <samu@mail>2013-01-18 20:35:34 (GMT)
committer samurey <samu@mail>2013-01-18 20:35:34 (GMT)
commit0f9bc57859625faad7c42c053bfc3604e5e3261a (patch)
tree573c86277dab88ae8e22ca1c8dd50321f47d0a79
parent695491ddafbfce530832415068f0c445b0af4b64 (diff)
Disenho de interfaz grafica con barrido automatico
-rw-r--r--calcularte_app.py123
1 files changed, 123 insertions, 0 deletions
diff --git a/calcularte_app.py b/calcularte_app.py
new file mode 100644
index 0000000..e61ee26
--- /dev/null
+++ b/calcularte_app.py
@@ -0,0 +1,123 @@
+#!/usr/bin/python
+import gtk
+import gobject
+
+
+OPTIONS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '-', '*', '/', 'Borrar', '(', ')', 'Aceptar']
+OPT_LENGHT = 5
+OPT_FILAS = 4
+DELAY = 1000
+
+
+class CalcularteApp():
+
+ def __init__(self):
+ window = gtk.Window()
+ vbox = gtk.VBox()
+ hbox = gtk.HBox()
+ label_historial = gtk.Label()
+ entry_visor = gtk.Entry()
+ table = gtk.Table(5,5, True)
+ boton = gtk.Button('boton falso')
+ window.connect('destroy', self.destroy)
+
+ label_historial.set_text('Historial')
+ #label_historial.justify()
+
+
+ window.add(hbox)
+ hbox.add(vbox)
+ hbox.add(label_historial)
+ vbox.add(entry_visor)
+ vbox.add(table)
+ vbox.add(boton)
+
+ OPTIONS.reverse()
+ for j in range(4):
+
+ for i in range(OPT_LENGHT):
+ button = gtk.Button()
+ option = OPTIONS.pop()
+ button.set_label(option)
+ button.connect('activate', self.__button_cb, entry_visor, boton, label_historial)
+ window.connect('key-press-event', self.__barrido_columnas_cb)
+ if option == 'Aceptar':
+ table.attach(button, i, i+3, j, j+1)
+ break
+ else:
+ table.attach(button, i, i+1, j, j+1)
+
+ window.show_all()
+ window.grab_focus()
+
+ #table.set_focus()
+ OPTIONS.reverse()
+
+ self._filas_index = 0
+ self._columnas_index = 0
+ self._flag_fila_columna = 0
+ gobject.timeout_add(DELAY, self.__timeout_cb, table)
+
+ def destroy(self, window, data=None):
+ gtk.main_quit()
+
+ def __button_cb(self, button, entry, boton, label):
+ if (button.get_label() == 'Aceptar'):
+ label.set_label(str(eval(entry.get_text())))
+ else:
+ entry.set_text(entry.get_text() + button.get_label())
+ self._flag_fila_columna = 0
+ self._filas_index = 0
+ self._columnas_index = 0
+ boton.grab_focus()
+
+
+ def __timeout_cb(self, table):
+ #self._button_index = (self._button_index + 1) % OPT_LENGHT
+ #buttons = hbox.get_children()
+ #button = buttons[self._button_index]
+ #button.grab_focus()
+ if self._flag_fila_columna == 0:
+ self._filas_index = (self._filas_index) % OPT_FILAS
+ buttons = table.get_children()
+ buttons.reverse()
+ buttons_focus = buttons[self._filas_index*OPT_LENGHT:self._filas_index*OPT_LENGHT+OPT_LENGHT]
+ for button in buttons:
+ button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('gray'))
+ for button in buttons_focus:
+ button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('red'))
+ self._filas_index += 1
+ else:
+
+ buttons = table.get_children()
+ buttons.reverse()
+
+ if self._filas_index == 4:
+ self._columnas_index = (self._columnas_index) % 3
+ buttons_focus = buttons[(self._filas_index-1)*OPT_LENGHT:(self._filas_index-1)*OPT_LENGHT+3]
+ else:
+ self._columnas_index = (self._columnas_index) % OPT_LENGHT
+ buttons_focus = buttons[(self._filas_index-1)*OPT_LENGHT:(self._filas_index-1)*OPT_LENGHT+OPT_LENGHT]
+
+ print self._filas_index
+ print self._columnas_index
+ button = buttons_focus[self._columnas_index]
+ button.grab_focus()
+
+ self._columnas_index += 1
+
+ #buttons = table.get(row = self._filas_index)
+
+
+ return True
+
+ def __barrido_columnas_cb(self, table, arg):
+ self._flag_fila_columna = 1
+
+
+
+
+
+if __name__ == "__main__":
+ my_app = CalcularteApp()
+ gtk.main()