In my GUI app, the table (a DetailedView
type widget) should grow/fit vertically and horizontally, as much as possible (up to the other elements.).
Right now it either fit the height OR width (but not both).
The DetailedView widget itself has no height
or style
attribute,
so it must to be contained in a toga.Box
container.
I tried to put each element inside a box
, and set flex
to the boxes, giving center
the largest flex value (top=1 : center=6 : bottom=1)
from toga.style.pack import COLUMN as COL, ROW
...
top = Box(style=Pack(direction=COL, flex=1), children=[textbox], background_color='blue')
center = Box(style=Pack(direction=COL, flex=4), children=[table], background_color='red')
bottom = Box(style=Pack(direction=ROW, flex=1), children=[button], background_color='green')
wrapper = Box(style=Pack(direction=COL, padding=9), children=[top, center, bottom])
results:
When the center
box’s direction is ROW
, then
- the height is fitted vertical CORRECTLY,
- but now the width is too narrow,
- adding “width=…” to the
center
box style changes only the box – but not the table element)
according to the docs, a box direction can be either ROW or COLUMN, not both.
I tried to put a box inside another box – no luck.
So – how to make the center element flex in all directions?