Unfortunately, I am not aware of any options that would allow me to control the vertical size of the enclosing region in CreateDialog and DialogNotebook. It seems that the size is not related to the value that is set in WindowSize for either of the options.

For example,

   Grid[{{""}}, Frame -> True, ItemSize -> {Scaled[1], Scaled[1]}]
  WindowSize -> {200, 100}

creates a dialog of the correct size. However, the vertical size of the enclosing region does not seem to be consistent with the size of the window:

enter image description here

The behaviour persists if DialogNotebook and CreateWindow are used instead of CreateDialog:

     ItemSize -> {Scaled[1], Scaled[1]},
     Frame -> True
   WindowSize -> {200, 100}
  WindowSize -> {200, 100},
  WindowMargins -> {{0, 0}, {0, 0}},
  ScrollingOptions -> {"VerticalScrollRange" -> Automatic}

Note: I am using Mac OS X Sierra 10.12.5 and Mathematica


Following a comment that was made by @Kuba, I thought that a potential worakaround could be to provide an embedding element with the fixed image size to Grid:

   ItemSize -> {Scaled[1], Scaled[0.8]},
   Frame -> True,
   Alignment -> Top
  ImageMargins -> 0,
  ImageSize -> {200, 100}
 WindowSize -> {220, 120}

However, unfortunately, the result was identical. The result was also similar when I tried to use Framed instead of Pane.

  • $\begingroup$ Using Scaled is always a pain because they do not respect different types of margins/frames in ways one would expect. So it works correctly, it just ignores cell margins. I'd go with something like: CreateDialog[Framed[ {""} , ImageSize -> {200, 100} ] , WindowSize -> All]. Keep in mind that The very bottom of CellMargins is missing. $\endgroup$ – Kuba Jun 1 '17 at 13:36
  • $\begingroup$ Do you need to use ItemSize? My point was to skip it, in Grid it works with line/characters units so it is tough to manage. Also the parent container is a cell so it will be tough to use scaled height of it, unless we force it like I've demonstrated. $\endgroup$ – Kuba Jun 1 '17 at 17:08
  • $\begingroup$ @Kuba Thank you for your comments. I decided to follow your advice and not use ItemSize. However, my question does come down to the ability to control the size of the enclosing object of the Grid that is embedded in CreateDialog. The horizontal size of the enclosing object seems to be governed through the WindowSize of CreateDialog. However, I could not find a way to control the vertical size of the enclosing object. Also, sorry for deleting the question with your comment - I decided that it was, effectively, duplicate/specialisation of the question in the link that you have posted. $\endgroup$ – user9230 Jun 2 '17 at 12:34
  • $\begingroup$ If you want to control vertical size you need to use a wrapper like my Framed, it is because Cell's height is automatically adjusted to fit contents, so the full height will be of height of the notebook, but then cell margins are ignored and you have misaligned content. $\endgroup$ – Kuba Jun 6 '17 at 13:20
  • $\begingroup$ @Kuba Thank you for your comment. The problem is that Grid does not seem to recognise Framed or Pane as its enclosing object, even if the Grid is located inside Framed or Pane. Please see the EDIT part in the formulation of the question. I used Pane as an example, but the effect is similar when Framed is used (the result is not entirely identical for Framed, but the vertical size of the Grid does not seem to be identical to the vertical size of the enclosing Framed when Scaled is set to 1. $\endgroup$ – user9230 Jun 6 '17 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy