Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgnacio Rodríguez <ignaciorodriguez@sugarlabs.org>2013-05-12 23:39:03 (GMT)
committer Ignacio Rodríguez <ignaciorodriguez@sugarlabs.org>2013-05-12 23:39:03 (GMT)
commitec068c67c694c773b8bfce70a31585eecab7f310 (patch)
treea436673541d5d8abdd3061148b83ad7da9007500
parent9af6827d67801d8b975828d1ee99491b3b61ae18 (diff)
Navegación en el TreeView con las teclas.
-rw-r--r--ListView.py24
1 files changed, 24 insertions, 0 deletions
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())