Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archivo.py4
-rw-r--r--calendario-gtk.py190
-rw-r--r--files/data/actividades.pkl2
-rw-r--r--files/data/efemerides.pkl2
4 files changed, 196 insertions, 2 deletions
diff --git a/archivo.py b/archivo.py
index 3651db1..dd2714e 100644
--- a/archivo.py
+++ b/archivo.py
@@ -45,7 +45,7 @@ def crear_modelo(indice, path):
modelo.append([0, vacio])
else:
- _log.debug('THE FILE EXISTS')
+ #_log.debug('THE FILE EXISTS')
archivo = open(path, 'rb')
dia = pickle.load(archivo)
contar = 1
@@ -74,7 +74,7 @@ def abrir_efemeride(path):
pickle.dump(texto, archivo)
else:
- _log.debug('THE FILE EXISTS')
+ #_log.debug('THE FILE EXISTS')
archivo = open(path, 'rb')
texto = pickle.load(archivo)
diff --git a/calendario-gtk.py b/calendario-gtk.py
new file mode 100644
index 0000000..d172cf7
--- /dev/null
+++ b/calendario-gtk.py
@@ -0,0 +1,190 @@
+# -*- coding: utf-8 -*-
+#
+#Copyright (C) 2010, Yader Velasquez
+#
+#This program is free software: you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from gettext import gettext as _
+from fecha import FechaUnix, FechaNormal
+from archivo import crear_modelo, abrir_efemeride, guardar_dato, borrar_dato
+import gtk
+#import logging
+
+
+class Calendario():
+ '''the sugar class'''
+
+ def __init__(self):
+ ''' init class'''
+ self.ventana = gtk.Window()
+ self.ventana.set_title('Calendario')
+ self.ventana.connect('destroy', self._cerrar_cb)
+ self.fecha_normal = FechaNormal()
+ #self._log = logging.getLogger('log principal')
+ self.path = 'files'
+
+
+
+ ######################### set interface ########################
+
+ #calendar
+ self.calendario = gtk.Calendar()
+ self.fecha = _('Hoy es ') + self.fecha_normal.fecha_actual()
+ self.texto_fecha = gtk.Label(self.fecha)
+
+ #daily activities
+ self.area_texto = gtk.ScrolledWindow()
+ self.area_texto.set_shadow_type(gtk.SHADOW_IN)
+ self.area_texto.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+
+
+ self.lista_fecha_t = self.calendario.get_date()
+ self.indice_dia_t = FechaUnix(self.lista_fecha_t)
+
+ self.modelo = crear_modelo(self.indice_dia_t.fecha_unix(), self.path)
+ self.actividades = gtk.TreeView(self.modelo)
+ self.area_texto.add(self.actividades)
+ self._crear_columna()
+
+ #ephemeris
+
+ self.area_efem = gtk.ScrolledWindow()
+ self.area_efem.set_shadow_type(gtk.SHADOW_IN)
+ self.area_efem.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ self.buffer = gtk.TextBuffer()
+
+ #ephemeris files
+
+ self.texto = abrir_efemeride(self.path)
+ if self.texto.has_key(self.fecha_normal.fecha_especial()):
+ self.buffer.set_text(self.texto[self.fecha_normal.fecha_especial()])
+
+ else:
+ self.buffer.set_text('Hoy no se celebra ninguna efemeride')
+
+ self.efemeride = gtk.TextView(self.buffer)
+ self.efemeride.set_editable(False)
+ self.efemeride.set_cursor_visible(False)
+ self.area_efem.add(self.efemeride)
+
+ #text input
+ self.area_entrada = gtk.ScrolledWindow()
+ self.area_entrada.set_shadow_type(gtk.SHADOW_OUT)
+ self.area_entrada.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ self.entrada = gtk.TextView()
+ self.entrada.set_size_request(0, 80)
+ self.area_entrada.add(self.entrada)
+
+ #buttons
+ self.boton1 = gtk.Button(_('Ingresar'))
+ self.boton2 = gtk.Button(_('Borrar'))
+
+ #frames
+ self.marco_efemeride = gtk.Frame(_('La efemeride del día de hoy es:'))
+ self.marco_efemeride.add(self.area_efem)
+ self.marco_actividades = gtk.Frame(_('Tus actividades para hoy son:'))
+ self.marco_actividades.add(self.area_texto)
+
+ #containers
+ self.contenedor_h = gtk.HBox()
+ self.contenedor_vd = gtk.VBox()
+ self.contenedor_vi = gtk.VBox()
+ self.sub_contenedor_h = gtk.HBox()
+ self.botones_contenedor = gtk.VBox()
+
+ #callbacks
+ self.calendario.connect('day_selected', self._dia_selec_cb)
+ self.boton1.connect('clicked', self._nuevo_ingreso_cb)
+ self.boton2.connect('clicked', self._borrar_fila_cb)
+
+ ########################### Add Blocks ################################
+ self.ventana.add(self.contenedor_h)
+ self.contenedor_h.pack_start(self.contenedor_vi, False, padding = 5)
+
+ self.contenedor_vi.pack_start(self.texto_fecha, False, padding = 5)
+ self.contenedor_vi.pack_start(self.calendario, False, padding = 5)
+ self.contenedor_vi.pack_start(self.marco_efemeride, padding = 5)
+
+ self.contenedor_h.pack_start(self.contenedor_vd, padding = 5)
+
+ self.contenedor_vd.pack_start(self.marco_actividades)
+ self.contenedor_vd.pack_start(self.sub_contenedor_h, False, padding = 15)
+
+ self.sub_contenedor_h.pack_start(self.area_entrada)
+ self.sub_contenedor_h.pack_start(self.botones_contenedor, False)
+ self.botones_contenedor.pack_start(self.boton1)
+ self.botones_contenedor.pack_start(self.boton2)
+
+ self.contenedor_h.show_all()
+ self.ventana.show()
+
+ def _dia_selec_cb(self, widget, data=None):
+ '''when a date is selected'''
+ self.lista_fecha = self.calendario.get_date()
+ self.indice_dia = FechaUnix(self.lista_fecha)
+ self.modelo = crear_modelo(self.indice_dia.fecha_unix(), self.path)
+ self.actividades.set_model(self.modelo)
+
+ def _borrar_fila_cb(self, widget, data=None):
+ '''deleted the selected row'''
+ self.seleccion = self.actividades.get_selection()
+ self.model, self.iter = self.seleccion.get_selected()
+ self.enlace = self.modelo.get_path(self.iter)
+ self.lista_fecha = self.calendario.get_date()
+ self.indice_dia = FechaUnix(self.lista_fecha)
+ self.indice_dia = self.indice_dia.fecha_unix()
+ borrar_dato(self.indice_dia, self.enlace, self.path)
+ self.modelo = crear_modelo(self.indice_dia, self.path)
+ self.actividades.set_model(self.modelo)
+
+
+ def _nuevo_ingreso_cb(self, widget, data=None):
+ '''when the user clicked on the save button,
+ the content is added to a python object and
+ is saved in a file'''
+ self.lista_fecha = self.calendario.get_date()
+ self.indice_dia = FechaUnix(self.lista_fecha)
+ self.indice_dia = self.indice_dia.fecha_unix()
+ self.buffer = self.entrada.get_buffer()
+ self.inicio, self.final = self.buffer.get_bounds()
+ self.cadena = self.buffer.get_text(self.inicio, self.final, False)
+ guardar_dato(self.indice_dia, self.cadena, self.path)
+ self.buffer.set_text(' ')
+ self.modelo = crear_modelo(self.indice_dia, self.path)
+ self.actividades.set_model(self.modelo)
+
+
+
+ def _crear_columna(self):
+ '''create the columns for the treeview'''
+ self.celda = gtk.CellRendererText()
+ self.numero = (_('Numero de actividad'))
+ self.actividad = (_('Actividades para hoy'))
+
+ self.columna = gtk.TreeViewColumn(self.numero, self.celda, text = 0)
+ self.actividades.append_column(self.columna)
+
+ self.columna = gtk.TreeViewColumn(self.actividad, self.celda, text = 1)
+ self.actividades.append_column(self.columna)
+
+ def _cerrar_cb(self, widget, data=None):
+ gtk.main_quit()
+
+ def main(self):
+ gtk.main()
+
+
+if __name__ == "__main__":
+ foo = Calendario()
+ foo.main()
diff --git a/files/data/actividades.pkl b/files/data/actividades.pkl
new file mode 100644
index 0000000..d67a0d1
--- /dev/null
+++ b/files/data/actividades.pkl
@@ -0,0 +1,2 @@
+(dp0
+. \ No newline at end of file
diff --git a/files/data/efemerides.pkl b/files/data/efemerides.pkl
new file mode 100644
index 0000000..d67a0d1
--- /dev/null
+++ b/files/data/efemerides.pkl
@@ -0,0 +1,2 @@
+(dp0
+. \ No newline at end of file