3
$\begingroup$

Starting from version 10.3 there is a documented way to specify a maximum allowed size for a graphical element via UpTo:

Table[Graphics[Circle[], Background -> LightGreen, ImageSize -> UpTo[50], 
  AspectRatio -> n], {n, {0.5, 1, 2}}]

output

But is it possible to specify a minimum allowed size as well?

P.S. The question is intended to collect methods for setting the minimum size for different graphic elements.

$\endgroup$
2
  • 1
    $\begingroup$ Is this what you want? ImageSize-> {{widthmin,widthmax]},{heightmin,heightmax}} $\endgroup$ Commented Aug 25, 2022 at 8:35
  • $\begingroup$ @DanielHuber The question is intended to collect methods for setting the minimum size for different graphic elements. This syntax logically follows from my answer, I just hadn't tested it. $\endgroup$ Commented Aug 25, 2022 at 9:35

1 Answer 1

4
$\begingroup$

At least for Pane, there are undocumented syntax forms of ImageSize for this:

ImageSize -> {{minWidth, maxWidth}, Automatic}

and

ImageSize -> {Automatic, {minHeight, maxHeight}}

where minWidth, maxWidth, minHeight and maxHeight can be a number or Full. Instead of Automatic can be a number or a symbolic size specification like Large, Small, etc.

These forms are found by searching through the InputForm of the bundled Documentation notebooks.


UPDATE

Testing shows that this syntax works also for Graphics:

Table[Graphics[Circle[], Background -> LightGreen, ImageSize -> {{35, 50}, 50}, 
  AspectRatio -> n], {n, {0.5, 1, 2}}]

out


UPDATE 2

It also works for Button:

Grid@Table[{Button["Text", Null, Background -> LightGreen, 
    ImageSize -> {{minWidth, Full}, Automatic}], 
   ImageSize -> {{minWidth, Full}, Automatic}}, {minWidth, 0, 90, 20}]

out

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.