[node-patches] Change in ovirt-node[master]: ui: Make page tab-able

fabiand at fedoraproject.org fabiand at fedoraproject.org
Thu Mar 21 14:44:33 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: ui: Make page tab-able
......................................................................

ui: Make page tab-able

A table pile was added which allows to cycle through it's children by
using TAB and SHIFT+TAB.
For now only the main page is tab-able.

rhbz#918999
rhbz#917498

Change-Id: I5889716ba1ad2c9b232c5ae6f466f04f98f387a5
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/ui/widgets.py
1 file changed, 21 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/52/13252/1

diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index ff47a22..8bedaf2 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -557,7 +557,7 @@
     def __init__(self, widgets, title=None):
 #        self._listwalker = urwid.SimpleListWalker(widgets)
 #        self._container = urwid.ListBox(self._listwalker)
-        self._container = urwid.Pile(widgets)
+        self._container = TabablePile(widgets)
         self._container_attrmap = urwid.AttrMap(self._container,
                                                 "plugin.widget.page")
         self._header = None
@@ -609,9 +609,24 @@
 
 
 class TabablePile(urwid.Pile):
+    """A pile where you can use (shift+)tab to cycle (back-)forward through the
+    children
+    """
     def keypress(self, size, key):
-        #if "tab" in key:
-        #    self.focus_position += 1
-        #elif "shift tab" in key:
-        #    self.focus_position -= 1
-        return (size, key)
+        new_pos = self.focus_position
+        delta = 0
+        LOGGER.debug("tab key: %s" % key)
+        if "tab" in key:
+            delta = 1
+        elif "shift tab" in key:
+            delta = -1
+        if delta:
+            LOGGER.debug("Setting focus to: %s" % new_pos)
+            while new_pos >= 0 and new_pos < len(self.contents):
+                new_pos += delta
+                new_pos = new_pos % len(self.contents)
+                if self.contents[new_pos][0].selectable():
+                    self.focus_position = new_pos
+                    break
+            LOGGER.debug("Focus on: %s" % self.focus)
+        return super(TabablePile, self).keypress(size, key)


--
To view, visit http://gerrit.ovirt.org/13252
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5889716ba1ad2c9b232c5ae6f466f04f98f387a5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list