James Reeves wrote: > Ian Ward wrote: >> It looks pretty good, but I wonder if there is a way to do it in a more >> duck-typing style. >> >> Instead of isinstance() perhaps we could check for a size_hint attribute >> and use it if it's there. That way people that know they are only using >> "my_widget" in one container could just do something like: >> my_widget.size_hint = 'weight' >> my_widget.size_hint_weight = 5 >> > Good idea, but why not just my_widget.size_hint_weight, or perhaps > my_widget.hint_weight? The size_hint attribute enforces a limit of a > single hint, but perhaps it might be neater to rely on precedence and > convention?
Hmm, that way there are three special variables and an ordering that users would have to remember. The way I suggested there is only one or two variables that would be required: size_hint is one of 'fixed' 'flow' or 'weight' and size_hint_weight is set only in the latter case. > On another note, I was thinking about keybindings, largely because I've > been customising them a lot since I switched to the Dvorak keyboard > layout. The signal system you have is really quite neat, and perhaps > underused. Instead of giving default keybindings to widgets like the > Columns and Pile widgets, maybe instead you could give them a set of > standard signals, such as "pile-down" and "column-left", that would > perform the same job. So you could do something like: Signals are intended as a notification of events from widgets, and yes they're new and not fully implemented through the library. What you're thinking of is like what I am planning to do with the "Commands" class in util.py. Widgets will look up what the command associated with a keypress in their keypress function and use the command instead of the keypress itself. Perhaps Keybinding is a better name. I might switch it to that. Ian _______________________________________________ Urwid mailing list [email protected] http://lists.excess.org/mailman/listinfo/urwid
