Message Boards Message Boards

2
|
5490 Views
|
6 Replies
|
5 Total Likes
View groups...
Share
Share this post:

How to create 'visible objects' with underlying data and functionality

Dear All,

My question is quite simple, there are several function that return objects/functions with pictorial representations:

enter image description here

I was wondering if there is a general construct to create your own object/function that shows some details, and to one can apply values to (like for ColorData apply a value between 0 and 1 to get a color). Mainly because all of them look very similar, so I guess there is a function that can do this...

POSTED BY: Sander Huisman
6 Replies
Posted 8 years ago

Thanks @Alexey Popkov. That is part of the story, I would like to make it such that it can be interpreted again, like the things colordata makes:

enter image description here

i.e. you can copy the output and add [value] to it, and it will execute... This seems to be a bit trickier to make...

POSTED BY: Sander Huisman

Anyone from Wolfram that could give me some insight? Surely there must be a function under the hood that can accomplish this...

@Leonid Shifrin @Vitaliy Kaurov @Jon McLoone @Michael Trott ?

POSTED BY: Sander Huisman

I am trying to dig through this myself, but I do not quite understand this. It might be related to the Low-Level Notebook Structure described also a bit in the tutorial Representing Textual Forms by Boxes. If you look with CMD+SHIFT+E on those structures you can see things like InterpretationBox and TemplateBox.

ColorData["Rainbow"]

enter image description here

InterpretationBox makes a formatting structure whose interpretation is not based on its appearance. For example, lets compute these:

Plot[Sin[x] Cos[5 x], {x, 0, 15/4}, PlotTheme -> "Minimal", Filling -> 0]
Integrate[Sin[x] Cos[5 x], {x, 0, 15/4}]

and now pack them as

enter image description here

Now the last output is interpreted as the expression in its second argument:

enter image description here

I doubt this is really helpful. I also would be curious about user-built case for such structures.

POSTED BY: Sam Carrettie

I didn't know about CMD+SHIFT+E. Very interesting structure indeed... I'll investigate a bit more, thanks a lot!

POSTED BY: Sander Huisman

Perhaps you also need to set Format[YourOwnFunction] := ....... ?

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract