[node-patches] Change in ovirt-node[master]: tui: Add simple position indicator to lists
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Thu Jan 10 17:14:21 UTC 2013
Fabian Deutsch has uploaded a new change for review.
Change subject: tui: Add simple position indicator to lists
......................................................................
tui: Add simple position indicator to lists
Change-Id: I77a1f6b99305e24b23b475da04ed36f8ddb69fe8
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/ui/widgets.py
1 file changed, 17 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/85/10885/1
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index d0167c0..6acd887 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -81,6 +81,8 @@
_label_attr = "table.label"
_header_attr = "table.header"
+ _position = 0
+
def __init__(self, label, header, items, height, enabled):
self.__label = urwid.Text(label)
self.__label_attrmap = urwid.AttrMap(self.__label, self._label_attr)
@@ -92,18 +94,31 @@
# self.__list_linebox = urwid.LineBox(self.__list)
def __on_item_change():
- widget, position = self.__list.get_focus()
+ widget, self._position = self.__list.get_focus()
+ self._update_scrollbar()
urwid.emit_signal(self, "changed", widget)
urwid.connect_signal(self.__walker, 'modified', __on_item_change)
self.__box = urwid.BoxAdapter(self.__list, height)
self.__box_attrmap = urwid.AttrMap(self.__box, self._table_attr)
+ self.__position_label = urwid.Text("", align="right")
+ self.__position_label_attrmap = urwid.AttrMap(self.__position_label,
+ self._label_attr)
+
self.__pile = urwid.Pile([self.__label_attrmap,
- self.__header_attrmap, self.__box])
+ self.__header_attrmap,
+ self.__box,
+ self.__position_label_attrmap])
+
+ self._update_scrollbar()
super(TableWidget, self).__init__(self.__pile)
+ def _update_scrollbar(self):
+ n = len(self.__list.body)
+ self.__position_label.set_text("(%s / %s)" % (self._position + 1, n))
+
def set_focus(self, n):
self.__list.set_focus(n)
--
To view, visit http://gerrit.ovirt.org/10885
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I77a1f6b99305e24b23b475da04ed36f8ddb69fe8
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