8
$\begingroup$

Button has this nice property that all Buttons in e.g. a Column will span to the size of the largest one:

Column @ Table[Button[i!], {i, 1, 16, 5}]

enter image description here

That is not the case in general:

Column @ Table[Framed[i!], {i, 1, 16, 5}]

enter image description here

Button has ImageSize -> Full but if we set it for Framed it get full width of the parent cell.

Is there a nice way to obtain Button's behavior in case of Framed/Pane and other GUI elements?

Possible workaround may be 'wrapper dependent', I'm especially interested in fixing this:

Column @ Table[PaneSelector[{True -> Button[i!]}, True], {i, 1, 16, 5}]

enter image description here

$\endgroup$
2
  • $\begingroup$ if cheating is allowed: Column@Table[Button[i!, {}, Appearance -> "Framed"], {i, 1, 16, 5}]? $\endgroup$
    – kglr
    Jan 20, 2018 at 22:09
  • $\begingroup$ @kglr yes it is but this is too specific :) I will add the real use case. $\endgroup$
    – Kuba
    Jan 20, 2018 at 22:11

1 Answer 1

2
$\begingroup$

I just dug up some option called BoxExpandable which does this job. I found it by inspecting the set of FrameBoxOptions:

CurrentValue[$FrontEndSession, {StyleDefinitions, "Input", 
   FrameBoxOptions}] /.

 s_Symbol?(StringStartsQ[SymbolName[#], "FrameBoxOptions"] &) :> 
  StringTrim[SymbolName[s], "FrameBoxOptions"]

{"BaseStyle" -> {}, "DefaultBaseStyle" -> "Framed", 
 "Enabled" -> Automatic, 
 "Appearance" -> {Automatic, "Framed", "Normal", Automatic}, 
 "Background" -> Automatic, "ImageSize" -> Automatic, 
 "ImageMargins" -> 0., "FrameMargins" -> Automatic, 
 "ContentPadding" -> True, "BaselinePosition" -> Automatic, 
 "Alignment" -> {Automatic, Automatic}, "BoxFrame" -> 1., 
 "FrameStyle" -> {}, "DefaultFrameStyle" -> {}, 
 "BoxExpandable" -> False, "StripOnInput" -> True, 
 "RoundingRadius" -> {0., 0.}, 
 "BoxMargins" -> {{0.4, 0.4}, {0.5, 0.5}}}

Unfortunately this only handles in initial case as it is missing from this:

CurrentValue[$FrontEndSession, {StyleDefinitions, "Input", 
   PaneSelectorBoxOptions}] /.

 s_Symbol?(StringStartsQ[SymbolName[#], 
      "PaneSelectorBoxOptions"] &) :> 
  StringTrim[SymbolName[s], "PaneSelectorBoxOptions"]

{"BaseStyle" -> {}, "DefaultBaseStyle" -> "PaneSelector", 
 "Enabled" -> Automatic, 
 "Appearance" -> {Automatic, "Palette", "Normal", Automatic}, 
 "Background" -> Automatic, "ImageSize" -> All, 
 "ImageMargins" -> Automatic, "FrameMargins" -> Automatic, 
 "ContentPadding" -> True, "BaselinePosition" -> Automatic, 
 "Alignment" -> {Automatic, Automatic}, "AutoAction" -> False, 
 "ContinuousAction" -> True, "TransitionDirection" -> Horizontal, 
 "TransitionDuration" -> 0.5, "TransitionEffect" -> Automatic}
$\endgroup$

Your Answer

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

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