5

That is all:

How can I set the width of columns in a Grid in terms of pixels instead of 'ems'?

To be more precisely, I want to create a grid that is 330 pixels wide, with 3 columns being 110 pixels wide each of them.

This could be a MWE:

Panel[Grid[{{"Hello", "World", "!"}}, Spacings -> 1, ItemSize -> All], ImageSize -> {330, 540}]

In this example, I tried to force the grid to have a width of 330, but I did not suceeded.

I am also asking for the case where you want each column to have a specific different width (in pixels, again). The previous MWE could serve as MWE for this question (without ItemSize -> All, of course).

EDIT: It is not mandatory to use Grid. I just thought it was the best way to show my results.

Vicent
  • 1,101
  • 6
  • 16
  • @Kuba I've just reached a very similar solution by my own, just now. Would you like to post yours as an answer? – Vicent Sep 16 '14 at 13:50

1 Answers1

9

Well, it was very easy. I found it by myself, and also @Kuba posted it as a comment (I think it has been deleted, though).

I can get what I want by using Scaled. It does not directly use pixels, but I can get the same results:

Panel[Grid[{{"Hello", "World", "!"}}, 
  Spacings -> 1, 
  ItemSize -> {{Scaled[1/3], Scaled[1/3], Scaled[1/3]}, Automatic}], 
 ImageSize -> {330, 540}]
Vicent
  • 1,101
  • 6
  • 16