From ec068c67c694c773b8bfce70a31585eecab7f310 Mon Sep 17 00:00:00 2001 From: Ignacio Rodríguez Date: Sun, 12 May 2013 23:39:03 +0000 Subject: Navegación en el TreeView con las teclas. --- diff --git a/ListView.py b/ListView.py index 6600e88..42661e1 100644 --- a/ListView.py +++ b/ListView.py @@ -22,6 +22,7 @@ class ListView(Gtk.TreeView): self.connect("row-expanded", self.__expandir) self.connect("row-collapsed", self.__colapsar) + self.connect("key-press-event", self.__tecla_presionada) self.show_all() @@ -104,6 +105,29 @@ class ListView(Gtk.TreeView): self.modelo.append(iter, ["Vacio", "Directorio"]) + + def __tecla_presionada(self, widget, event): + tecla = event.keyval + + model, iter = self.get_selection().get_selected() + + if iter is None: return + + path = self.get_model().get_path(iter) + + if tecla == 65361: + if self.row_expanded(path): + self.collapse_row(path) + + elif tecla == 65363: + if not self.row_expanded(path): + self.expand_to_path(path) + + else: + pass + + return False + if __name__ == "__main__": Scroll = Gtk.ScrolledWindow() Scroll.add_with_viewport(ListView()) -- cgit v0.9.1