diff options
author | flavio <fdanesse@gmail.com> | 2012-04-25 14:18:29 (GMT) |
---|---|---|
committer | flavio <fdanesse@gmail.com> | 2012-04-25 14:18:29 (GMT) |
commit | 40c72c67b36bd80a4dd936a8bc889526dd62b2af (patch) | |
tree | 1382e02285863833dce1eb916b57377107d24d68 /CeibalNotifica.py | |
parent | ef0afced91216be8953a7ee05516c4d1f729d82f (diff) |
Correcciones y Agrego Eliminar Registro
Diffstat (limited to 'CeibalNotifica.py')
-rw-r--r-- | CeibalNotifica.py | 63 |
1 files changed, 23 insertions, 40 deletions
diff --git a/CeibalNotifica.py b/CeibalNotifica.py index 396e3de..18d949d 100644 --- a/CeibalNotifica.py +++ b/CeibalNotifica.py @@ -19,14 +19,10 @@ import os import gtk import sys import gobject - from store import * - BASE = os.path.dirname(__file__) - class CeibalNotifica(gtk.Window): - def __init__(self): super(CeibalNotifica, self).__init__() self.set_title("Ceibal Notifica") @@ -38,7 +34,7 @@ class CeibalNotifica(gtk.Window): self.text_buffer = None self.text_view = None - + self.store = None self.listore_model = None self.modelsort = None self.notify_store = None @@ -60,6 +56,7 @@ class CeibalNotifica(gtk.Window): self.text_buffer = gtk.TextBuffer() self.text_view = gtk.TextView(buffer=self.text_buffer) + self.text_view.set_editable(False) hpanel = gtk.HPaned() self.store = Store(db_filename="prueba.db") @@ -81,12 +78,14 @@ class CeibalNotifica(gtk.Window): def delete_notify(self, widget, path): iter = widget.get_model().get_iter(path) - id_registro = widget.get_model().get_value(iter, 0) - print "Eliminar item", id_registro + id_registro = int(widget.get_model().get_value(iter, 0)) + self.store.db.remove_message(id_registro) + self.load_notify() def load_notify(self): notificaciones = self.store.db.get_messages([]) self.listore_model.clear() + self.text_buffer.set_text('') for notif in notificaciones: self.add_notify(notif) @@ -105,7 +104,6 @@ class CeibalNotifica(gtk.Window): def salir(self, widget=None): sys.exit(0) - class ListoreModel(gtk.ListStore): def __init__(self): gtk.ListStore.__init__(self, gobject.TYPE_STRING, @@ -117,15 +115,12 @@ class ListoreModel(gtk.ListStore): ''' set_fav(self, id_msg, fav=True) marcará favorito. remove_message(self, id_msg) borra un registro en la base.''' - - class Notify_Store(gtk.TreeView): __gsignals__ = {"show_notify": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING, )), "delete_notify": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, ))} - - def __init__(self, model): + def __init__(self, model): gtk.TreeView.__init__(self, model) self.set_property("rules-hint", True) self.add_events(gtk.gdk.BUTTON2_MASK) @@ -140,14 +135,14 @@ class Notify_Store(gtk.TreeView): self.get_model(), True) def set_columns(self): - self.append_column(self.make_column('id', 0, True)) + self.append_column(self.make_column('id', 0, False)) self.append_column(self.make_column('Prioridad', 1, True)) self.append_column(self.make_column('Título', 2, True)) - self.append_column(self.make_column('Notificación', 3, True)) - self.append_column(self.make_column('Lanzamiento', 4, True)) + self.append_column(self.make_column('Notificación', 3, False)) + self.append_column(self.make_column('Lanzamiento', 4, False)) self.append_column(self.make_column('Expira', 5, True)) self.append_column(self.make_column('Tipo', 6, True)) - self.append_column(self.make_column('Favorito', 7, True)) + self.append_column(self.make_column('Favorito', 7, False)) def make_column(self, text, index, visible): render = gtk.CellRendererText() @@ -165,14 +160,17 @@ class Notify_Store(gtk.TreeView): boton = event.button pos = (int(event.x), int(event.y)) tiempo = event.time - path, col, x, y = widget.get_path_at_pos(pos[0], pos[1]) - if boton == 1: - return - elif boton == 3: - self.get_menu(boton, pos, tiempo, path) - return - elif boton == 2: - return + try: + path, col, x, y = widget.get_path_at_pos(pos[0], pos[1]) + if boton == 1: + return + elif boton == 3: + self.get_menu(boton, pos, tiempo, path) + return + elif boton == 2: + return + except: + pass def get_menu(self, boton, pos, tiempo, path): menu = gtk.Menu() @@ -202,19 +200,4 @@ d['expires'] = datetime.date(2012, 6, 21) d['type'] = "Prueba tipo" d['fav'] = 0 d.close() - -filename = os.path.join('/tmp', 'notify_1') -d = shelve.open(filename) -d['id'] = 1 -d['title'] = "Prueba Titulo1" -d['text'] = "Prueba Texto1" -d['priority'] = 1 -d['launched'] = datetime.date(1972, 6, 21) -d['expires'] = datetime.date(2013, 6, 21) -d['type'] = "Prueba tipo1" -d['fav'] = 1 -d.close() - -store = Store(db_filename="prueba.db") -mensaje = store.db.get_messages([]) -print mensaje''' +''' |