Message Boards Message Boards

0
|
8981 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to handle arrays of selectable images in Mathematica

Posted 9 years ago

Hi everybody,

I'm trying to create an interactive cell with Mathematica and i have some problems developing it. I have, for example, three arrays which are related to buttons. The arrays contain images and each image is related to a button. In the beginning, a button of the first array is selected by default. When i select a button related to the second or third array, i would like that the button related to the first array gets unselected. I have tried everything so far; conditional statements, switch, ... but, i was not able to solve the problem. Could someone please help me?

In the attached file you can find the code that i typed.

Attachments:
POSTED BY: D H D
4 Replies
Posted 9 years ago

The dynamic grid works properly and shows the image that is selected. The problem is the command "Manipulate". I want to add an interactive cell to our webpage, that's why i tried to do it with the command "Manipulate". The attached example shows how it should look like.

Attachments:
POSTED BY: D H D

I think SetterBar automatically selects equivalents if you put multiples in (thus within setterbar, the problem is using duplicate images).

Try nine distinct images in the following:

Column[{SetterBar[Dynamic[i], nineimages, Appearance -> "Horizontal" -> {3, 3}], Pane[Dynamic[i], {260, 260}]}]

POSTED BY: David Gathercole
Posted 9 years ago

Hi David,

Thank you for your reply. I want my application to do exactly what the setterbar does but i want this to show the image on the pane. I don't really know whether i can develop the application without the command "Manipulate". I just want to make the interactive cell and put it on our website. What is the command "Manipulate" for? Your solution has exactly the same problem as mine has. It only shows the first three images and the buttons below are selected at the same time.

POSTED BY: D H D

I believe your objective here is to have a grid of buttons, yet control generates rows.

At present your solution is to try and combine three different manipulate variables. Unfortunately things are not set up to do this easily!

Luckily we can generate a button grid by bypassing Control and using SetterBar. For example try:

{SetterBar[Dynamic[x], Range[6], 
  Appearance -> "Horizontal" -> {3, 3}], Dynamic[x]}

Unluckily Manipulate doesn't take explicit SetterBar controls! It appears Manipulate only eats Controls (which can yield SetterBar controls), and I can't find a way to pass the above appearance specification. Though it may be possible. Must you explicitly use Manipulate for your application? Does a dynamic setter in another context suffice?

Find a solution attached.

Attachments:
POSTED BY: David Gathercole
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