in reply to Prima: How to get a "table" layout?

Hello Harald,

I believe the code by AnonymousMonk from Jan 19 2025 19:07, with text "Adjusting cells height per row and, thus, simulating a table.." is the best approach if you want to use the packer geometry. Said that, I don't think that there's anything wrong in counting pixels; the code might be less elegant, that's true, but gives you all the flexibility when a geometry manager cannot do what you want. It comes down basically to knowing the height() of your first $label and first $input and just go all the way down from there. If you are concerned about the various font heights and how this will look like with other widgets with sizes not related to the default font (f ex an image that is always 100x100), you indeed can test that with Prima::Stress, and you can also use the .designScale() property and safely design your window layout the way you see it on your own screen - just find out what is your default widget font width and height and set these in the .designScale() property.

There's another thing though that I think can be tricky, multiline labels. Labels are flexible and can both adapt your text in a given size, and adapt their sizes after the text - you would most probably need .autoWidth and .wordWrap.

But I must admit that neither of these solution is as elegant as html's table, or Tk::grid for that matter. If there is interest, I might just add this feature to Prima, like I did back then with the placer and the packer.

Hope that makes sense

  • Comment on Re: Prima: How to get a "table" layout?

Replies are listed 'Best First'.
Re^2: Prima: How to get a "table" layout?
by haj (Vicar) on Jan 20, 2025 at 23:17 UTC
    I believe the code by AnonymousMonk from Jan 19 2025 19:07, with text "Adjusting cells height per row and, thus, simulating a table.." is the best approach if you want to use the packer geometry.

    Indeed, that's probably what I will do. I might still keep my original widget hierarchy and adjust cell widths per column instead of cell heights per row, though, because adding variables is easier that way (add one row instead of one cell in every row). It is also closer to the HTML table model.

    All that said: It is neither urgent nor important. I was just hoping that the problem has already been solved by someone else.

    Thank you a lot for maintaining Prima!