Rebecca Breu wrote:
Quoting Pedro Jorge Caridade <[EMAIL PROTECTED]>:
Hello again
I'm having some problems running some examples with version 0.9.8.1. For
example, rbreu_fc.py and rbreu_scrollbar.py.
It seems that some stuff has changed in urwid since I last tried my examples.
I'm very busy right now, I can't fix it until next week. :(
This patch fixes the crash due to canvas changes, but the scrollbar
seems to be stuck to the top now.. I'll have to keep looking to see
what causes that.
Index: rbreu_scrollbar.py
===================================================================
--- rbreu_scrollbar.py (revision 142)
+++ rbreu_scrollbar.py (working copy)
@@ -100,15 +100,15 @@
widget
"""
- handle_canvas = urwid.Text(handle[0]).render((1,))
- self.handle_char = handle_canvas.text[0];
- self.handle_attr = handle[1];
- self.handle_charset = handle_canvas.cs[0][0][0];
+ self.handle_widget = urwid.SolidFill(handle[0])
+ if handle[1] is not None:
+ self.background_widget = urwid.AttrWrap(self.handle_widget,
+ handle[1])
- background_canvas = urwid.Text(background[0]).render((1,))
- self.background_char = background_canvas.text[0];
- self.background_attr = background[1];
- self.background_charset = background_canvas.cs[0][0][0];
+ self.background_widget = urwid.SolidFill(background[0])
+ if background[1] is not None:
+ self.background_widget = urwid.AttrWrap(self.background_widget,
+ background[1])
self.middle = middle;
self.top = top;
@@ -156,32 +156,13 @@
(middle, top, bottom) = hamilton_allocation([self.middle, self.top,
self.bottom], maxrow);
- text_list = [self.background_char] * top + \
- [self.handle_char] * middle + \
- [self.background_char] * bottom;
+ pile = urwid.Pile([('fixed', top, self.background_widget),
+ ('fixed', middle, self.handle_widget),
+ ('fixed', bottom, self.background_widget)])
- #Length of chars maybe > 1 for escape sequences
- handle_rl = len(self.handle_char);
- background_rl = len(self.background_char);
+ return pile.render((maxcol, maxrow), focus)
- attr_list = [[(self.background_attr, background_rl)] \
- for i in range(top)] + \
- [[(self.handle_attr, handle_rl)] \
- for i in range(middle)] + \
- [[(self.background_attr, background_rl)] \
- for i in range(bottom)]
- charset_list = [[(self.background_charset, background_rl)] \
- for i in range(top)] + \
- [[(self.handle_charset, handle_rl)] \
- for i in range(middle)] + \
- [[(self.background_charset, background_rl)] \
- for i in range(bottom)]
-
-
- return urwid.Canvas(text_list, attr_list, charset_list)
-
-
def read_move(self, maxrow, length):
"""
Updates the position of the scrollbar and returns the amount of lines
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid