0
$\begingroup$

I used a ButtonBar. When I click a button (in Output) it unhide all my hidden code (Input). How to overcome this issue?

UPD: requested example

Input:

ButtonBar[{
  "Subsuperscript[E, concrete, creep]"   :> Print[Ebτ],
  "Subsuperscript[E, concrete, Bulichev]":> Print[EbBul],
  "Subsuperscript[γ, b1-3, γf]"          :> Print[γb3f /1.3],
  "Subsuperscript[γ, b1-4, γf]"          :> Print[γb1 γb2 γb3 γb4 /1.3],
  "Subscript[γ, b1-4]"                   :> Print[γb4f],
  "Subsuperscript[RR, b1, γ3]"           :> Print[Rb1 γb3f ],
  "Subsuperscript[R, b1, γ4]"            :> Print[Rb1 γb4f],
  "Subscript[σ, z]"                      :> Print[σz]
}]

After evaluation there eight buttons in Output. I double clicking the output cell and hide Input cell. But after clicking on any button the Input opens. I want to make it hidden until i want to open it manually.

$\endgroup$
1
$\begingroup$

If you manually select the input cell, you can uncheck the "Open" property in: the top-bar menu: Cell > Cell Properties . It should stay closed until you open it again.

enter image description here

turns into:

enter image description here

$\endgroup$
3
$\begingroup$

You can select the cell with the code, go to Menu/Cell/CellProperties and uncheck "Open". In this case, your code cell will always be closed.

In addition, do not write the string:"Subsuperscript[E, concrete, creep]", as the button name, since it makes the button name the whole string as you write it, that is, with the word "Subsuperscript", the square brackets etc. In addition, the buttons are too small:

enter image description here

The better way please see below. Because of my laziness I only make a bar with two of your buttons:

ButtonBar[{"\!\(\*SubsuperscriptBox[\(E\), \(concr\), \(creep\)]\)" :>
    Print[Eb\[Tau]], 
  "\!\(\*SubsuperscriptBox[\(E\), \(concr\), \(Bulichev\)]\)" :> 
   Print[EbBul]}, ImageSize -> Medium]

looking as follows:

enter image description here

Have fun!

$\endgroup$
  • $\begingroup$ Thank you! About button names: in Mathematica I use ctrl+6 -> ctr+5 and it got just the same names as yours. In my example the string transformed after "copy as -> plain text" . Anyway, thank you for info, it will come in handy. $\endgroup$ – E. Delacroix Aug 18 '17 at 7:46
  • $\begingroup$ Yes, I also type this using shortcuts, a bit different, since I have another keyboard. And this: "\!\(\*SubsuperscriptBox[\(E\), \(concr\), \(creep\)]\)" it is simply how it is transformed when I copy-paste my expression into the StackExchange window. Though, you may, of course, use a box language. $\endgroup$ – Alexei Boulbitch Aug 18 '17 at 7:49
  • $\begingroup$ oh... Now I see where was a problem... I just need to simple copy (not as a plain text) in future... Thank you! $\endgroup$ – E. Delacroix Aug 18 '17 at 7:53
  • $\begingroup$ @E.Delacroix and Alexei, something shorter: MapAt[ToExpression[#, StandardForm, HoldForm] &, #, {1, All, 1}] &@ ButtonBar[{ ...}, FrameMargins -> 5] $\endgroup$ – Kuba Aug 18 '17 at 8:29
1
$\begingroup$

You can add following code to the cell whose code you want to hide:

SetOptions[EvaluationCell[], CellOpen -> Dynamic[Not@codehide]];

This will make it hidden according to the value of the codehide. Just evaluate it to True if you want hide the code or otherwise to show it. I usually put the checkbox onto the always visible part of the interface to have the real-time access to "codehiding"

$\endgroup$

Your Answer

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

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