Can TabView be modified to show images for navigation instead of vector art or text?

I have see code for TabView in the doc’s that provide something close to what I need:

TabView[Tooltip[
Show[CountryData[#, “Shape”], ImageSize -> {30, 30}], #] ->
DateListPlot[CountryData[#, {{“GDP”}, {1970, 2005}}],
ImageSize -> Medium] & /@ CountryData[“GroupOf10”]]

Which provides the outlines of countries in each tab for navigation. What I need is a way to use images for each tab navigation. How can that be done?

=================

=================

2 Answers
2

=================

Actually there is nothing you have to really do, just get some images (you can of course just as well Import your own ones):

img1 = ExampleData[{“TestImage”, “Tree”}];
img2 = ExampleData[{“TestImage”, “Truck”}];

and use them where you’d otherwise use strings or whatever:

TabView[{
img1 -> “tree”,
img2 -> “truck”
}]

it looks somewhat better if the images have the same size:

TabView[{
ImageResize[img1, {100, 100}] -> “tree”,
ImageResize[img2, {100, 100}] -> “truck”
}]

The trick here is that “everything is an expression” in Mathematica, and TabView accepts any kind of expression for the tab-labels or content, and so do many other similar functions. Unlike in my example you could even literally copy & paste the images into your code and it would work, but I don’t think that is usually a good idea…

  

 

Wow, very simple! Thanks Albert Retey !
– R Hall
Dec 15 ’15 at 21:09

fig1 = Graphics3D[Sphere[], ImageSize -> 30];
fig2 = Graphics3D[Cuboid[], ImageSize -> 30];
TabView[{fig1 -> “My first tab”, fig2 -> “My second tab”}]