changeset 19:0b83dd2b15d1

Primitivus: misc improvments on TabsContainer/FocusFrame - FocusFrame: better management of keypress - TabsContainer: new addFooter method, to add a widget on the bottom of the container
author Goffi <goffi@goffi.org>
date Mon, 09 Aug 2010 21:58:28 +0800
parents bdc83e857093
children 333a62fab0e3
files frontends/primitivus/custom_widgets.py
diffstat 1 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/primitivus/custom_widgets.py	Mon Aug 09 19:09:13 2010 +0800
+++ b/frontends/primitivus/custom_widgets.py	Mon Aug 09 21:58:28 2010 +0800
@@ -816,6 +816,10 @@
     """Frame which manage 'tab' key"""
 
     def keypress(self, size, key):
+        ret = urwid.Frame.keypress(self, size, key)
+        if not ret:
+            return
+        
         if key == 'tab':
             focus_list = ('header','body','footer')
             focus_idx = focus_list.index(self.focus_part)
@@ -826,7 +830,7 @@
                 if widget!=None and widget.selectable():
                     self.set_focus(focus_name)
 
-        return urwid.Frame.keypress(self, size, key)
+        return ret 
 
 class TabsContainer(urwid.WidgetWrap):
     signals = ['click']
@@ -835,14 +839,14 @@
         #self._current_tab = 0
         self._buttons_cont = ColumnsRoller()
         self.tabs = []
-        self.__frame = urwid.Frame(urwid.Filler(urwid.Text('')),urwid.Pile([self._buttons_cont,urwid.Divider(u"─")]))
+        self.__frame = FocusFrame(urwid.Filler(urwid.Text('')),urwid.Pile([self._buttons_cont,urwid.Divider(u"─")]))
         urwid.WidgetWrap.__init__(self, self.__frame)
 
-    """def selectable(self):
-        return True
-    
     def keypress(self, size, key):
-        return key"""
+        if key=='tab':
+            self._w.keypress(size,key)
+            return
+        return self._w.keypress(size,key)
 
     def __buttonClicked(self, button, invisible=False):
         """Called when a button on the tab is changed,
@@ -880,6 +884,12 @@
         self.__appendButton(name)
         return listbox
 
+    def addFooter(self, widget):
+        """Add a widget on the bottom of the tab (will be displayed on all pages)
+        @param widget: FlowWidget"""
+        self._w.footer = widget
+    
+
 ## DECORATORS ##
 class LabelLine(urwid.LineBox):
     """Like LineBox, but with a Label centered in the top line"""