Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.9K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Holding Argument of DisplayForm for use as labels in forms

Posted 3 years ago

Hey,

for example when creating forms it would be nice to have DisplayForms as labels. But a problem is that the argument will be evaluated, which is not suitable when using a DisplayForm as a label.

here is a minimal example to show what I would like to do:

d = {2, 3, 4, 5}; c = {1, 2, 3, 4, 5, 6, 7, 8};
frac = Module[{}, RandomChoice[d]/RandomChoice[c]];
FormFunction[{
    "first" -> <|"Interpreter" -> "Number", 
    "Label" -> DisplayForm[frac] + DisplayForm[frac]|>}, f, 
    AppearanceRules -> {"SubmitLabel" -> "Go!"}}
]

this will yield an evaluated fraction as show in the screenshot. What I would like is to have the label unevaluated, in this example, a sum of two fractions.

Of course in this case using StringForm would be a workaround. But I would like to know whether there is some way e.g. using Hold, Inactivate or such to generally prevent evaluation for using DisplayForms as labels.

Attachment

Attachments:
POSTED BY: Timm Reinisch
4 Replies
d = {2, 3, 4, 5}; c = {1, 2, 3, 4, 5, 6, 7, 8};
frac := HoldForm[Evaluate@RandomChoice[d]]/
   HoldForm[Evaluate@RandomChoice[c]];
FormFunction[{"first" -> <|"Interpreter" -> "Number", 
    "Label" -> DisplayForm[frac] + DisplayForm[frac]|>}, f, 
 AppearanceRules -> {"SubmitLabel" -> "Go!"}
 ]
POSTED BY: Robert Nowak

Another way:

d = {2, 3, 4, 5}; c = {1, 2, 3, 4, 5, 6, 7, 8};
frac = FractionBox[RandomChoice[d], RandomChoice[c]];
FormFunction[{"first" -> <|"Interpreter" -> "Number", 
    "Label" -> Inactive[Plus][DisplayForm[frac], DisplayForm[frac]]|>},
 f, AppearanceRules -> {"SubmitLabel" -> "Go!"}]
POSTED BY: Gianluca Gorni
Posted 3 years ago
Posted 3 years ago
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard