Closed danschwarz closed 1 year ago
Yes, UrwidImage
isn't a fixed widget. As a matter of fact, almost all built-in urwid widgets aren't.
The reason being, I couldn't think of any way to compute a valid image size without maxcols or maxrows i.e an empty size tuple, and to be fair, it doesn't make much sense anyways.
Use Columns([..., UrwidImage(...), ...])
instead i.e as a box/flow widget with weighted width within the Columns
widget. Or with given with i.e Columns([... , (width, UrwidImage(...)), ...])
.
EDIT: Note that ("pack", widget)
is quite different for a Pile
widget. In this case, widget
is treated as a flow widget, which UrwidImage
is.
With Columns(<list of UrwidImage widgets>, 1)
:
With
Columns([("pack", image_w) for image_w in <list of UrwidImage widgets>], 1)
Only the first widget is rendered and fills the entire Columns
widget. So, I guess that's what you're experiencing.
This is totally intended behavior. See:
Though, I guess i need to change "packed" to "fixed". That was a mistake.
I'm really sorry, I should've asked first. Any ideas on how to compute the size for a fixed image widget?
Only the first widget is rendered and fills the entire Columns widget. So, I guess that's what you're experiencing.
That is what I'm experiencing. After I wrote up the issue, I realized that it wasn't a zero width situation, but a too-wide situation preventing the display of the image.
I'm able to work around this issue by simply not attempting to pack the UrwidImage. As long as I follow it with another column of sufficient weight, the UrwidImage gets displayed at minimum width, which is what I am after.
Any ideas on how to compute the size for a fixed image widget? Given that you do centering and (optionally) upscaling, I don't think it is possible to know the size outside of render()
So, fine to close this out as wontfix. Thanks.
You're welcome.
Thanks for all your reports, suggestions and help.
I have an urwid.Columns widget in which I am placing text in some columns, an UrwidImage in another. ("pack", urwid.Text("SomeTextHere")) works fine. ("pack",BoxAdapter(UrwidImage(...)),1) causes the UrwidImage to disappear on render. I think it may be calculating zero-width. Thoughts?