[Urwid] Rendering standout attribute across entire Columns widget

Jacob Courtneay jacob at sporkexec.com
Tue Sep 6 23:45:47 EDT 2011


So I spent a few nights trying to implement the chaining behavior as discussed.
I didn't get very far with this, because:
- This code[1] isn't the easiest thing to wrap your head around, particularly
  when you need to duplicate the behavior with a few added quirks ('*' keys and
  appending the attribute).
- Using a dictionary, the logic for '*' and partial keys needs to be in every
  Canvas content method AFAICT.
- util._tagmarkup_recurse and I don't get along. I don't exactly understand it's
  purpose (I asked about it in my last message) and sparsely documented, but 
  chances are I just suck too much to understand it.
- I felt like I was going through all kinds of hacky contortions just to barely
  make it work.

I got fed up with that, then sat down tonight and did it in about 10 minutes.[2]
The twist is that I did it as a special case of the callable mapping idea I
brought up earlier. It still doesn't address Text markup (you're on your own
there, I've asked for help). IMO this way is pretty clear/simple, though.

Actually I just noticed I haven't done the palette lookup in this branch.
That's pretty easy, I'll get it tonight.

[1] https://github.com/wardi/urwid/blob/master/urwid/canvas.py#L775
[2] https://github.com/sporkexec/urwid/commits/AttrMap_callable

Any comments?
Doing this with raw dictionaries gets very nasty from what I can tell.

-- Jacob




More information about the Urwid mailing list