Discussion:
[Urwid] Columns container don't change focus, is it normal ?
Goffi
2014-01-28 18:12:52 UTC
Permalink
G'day,

I have a small question with the new behaviour with Columns.contents.

I create a Columns container with just a Text Widget (so it's not selectable).
columns.focus = 0 once created.

After that, I append a selectable widget (say an EditBox):

columns.contents.append((edit_box, columns.options()))

but the focus doesn't change and the columns stay not selectable. I would
expect that when there is no selectable widget in a Columns container, if I
had one it take focus and columns become selectable.

I can do it manually something, just after append widget to columns:
if not columns.selectable() and widget.selectable():
columns.focus_position = len(columns.contents)-1

So do I do something wrong and is the behaviour normal ?

Thanks
Goffi
Ian Ward
2014-01-29 01:39:14 UTC
Permalink
Post by Goffi
G'day,
I have a small question with the new behaviour with Columns.contents.
I create a Columns container with just a Text Widget (so it's not selectable).
columns.focus = 0 once created.
columns.contents.append((edit_box, columns.options()))
but the focus doesn't change and the columns stay not selectable. I would
expect that when there is no selectable widget in a Columns container, if I
had one it take focus and columns become selectable.
columns.focus_position = len(columns.contents)-1
So do I do something wrong and is the behaviour normal ?
Yes, this is the normal behaviour. The only time Columns will scan
through the widgets for a selectable widget is when it is created,
after that you would need to change the focus yourself.

Maybe this should be changed for the Columns, Pile and GridFlow
widgets when their focus is not selectable. What about edge cases like
a selectable widget that becomes unselectable?
Goffi
2014-01-29 11:39:17 UTC
Permalink
Post by Ian Ward
Yes, this is the normal behaviour. The only time Columns will scan
through the widgets for a selectable widget is when it is created,
after that you would need to change the focus yourself.
Ok thanks. It's not a big deal to add two lines after appending a widget to
Columns.contents anyway
Post by Ian Ward
Maybe this should be changed for the Columns, Pile and GridFlow
widgets when their focus is not selectable. What about edge cases like
a selectable widget that becomes unselectable?
This case is IMHO not common, and if it happen the developer should know it
and update focus himsel.

Loading...