changeset 227:1b29cc99f457

Use ListWidget for EntryList and ProjectList
author Björn Ricks <bjoern.ricks@intevation.de>
date Fri, 05 Apr 2013 20:16:47 +0200
parents f8571308abef
children 37010cd332d9
files getan/view.py
diffstat 1 files changed, 7 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/getan/view.py	Fri Apr 05 20:16:06 2013 +0200
+++ b/getan/view.py	Fri Apr 05 20:16:47 2013 +0200
@@ -139,6 +139,8 @@
             3: "tree",
     }
 
+    node_class = ProjectNode
+
     def __init__(self, controller, rows):
         self.selection = []
         self.size = ()
@@ -167,7 +169,6 @@
             self.rows = self.create_project_tree()
         else:
             self.rows = self.create_project_list()
-        self.listbox = urwid.ListBox(urwid.SimpleListWalker(self.rows))
 
     def create_project_list(self):
         return [ProjectNode(x) for x in sorted(self.raw_rows,
@@ -247,29 +248,13 @@
 
 class EntryList(ListWidget):
 
+    node_class = EntryNode
+
     def __init__(self, rows):
-        self.selection = []
-        self.top       = 0
-        self.size      = ()
-        self.focused   = 0
-        self.rows      = [EntryNode(x) for x in rows]
-        listbox        = urwid.ListBox(urwid.SimpleListWalker(self.rows))
-        self.body      = urwid.LineBox(urwid.Padding(urwid.AttrWrap(
-            listbox, 'entry_body'),
-            ('fixed left', 1), ('fixed right', 1)))
-        self.header    = urwid.LineBox(urwid.AttrWrap(urwid.Text(
-            "\n%s\n"
-            % _('Last entries')),'entry_header'))
-        self.footer    = urwid.AttrWrap(urwid.Text(""), 'entry_footer')
-        self.frame     = urwid.Frame(self.body, header=self.header,
-                                     footer=self.footer)
+        logger.debug("Init EntryList %s" % id(self))
+        super(EntryList, self).__init__("Entries", rows)
+        self.set_footer_text("", "entry_footer")
 
-    def set_rows(self, rows):
-        if rows:
-            self.rows = [EntryNode(x) for x in rows]
-        else:
-            self.rows = []
-        self._update_view()
 
 class GetanView(urwid.WidgetWrap):
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)