0
$\begingroup$

I really need some help from you guys! I did not find anything similar here and I am trying hard to learn Wolfram Mathematica, but I do not understand this part.

So the thing is:

I have a list of words and I wanna put those words inside ExampleData["TestImage", "words here"], one by one. It's really important that it needs to be dynamic as the list will change every time.

Could you please give me some tips how to do it? I am really lost!

$\endgroup$
1
$\begingroup$

I'm not 100% sure I understand what you have in mind, so correct me if I'm way off, but you can get all the names of the "TestImage" examples like this:

names = ExampleData["TestImage"][[All, 2]]

(* {"Aerial", "Aerial2", "Airplane", "Airplane2", "Airport", "APC",  "Apples", "Boat", "Bridge", "CarAndAPC", "CarAndAPC2",  "ChemicalPlant", "Clock", "Couple", "Couple2", "Elaine", "F16",  "Flower", "Girl", "Girl2", "Girl3", "Gray21", "House", "House2",  "JellyBeans", "JellyBeans2", "Lena", "Man", "Mandrill", "Marruecos",  "Moon", "Numbers", "Peppers", "RadcliffeCamera", "ResolutionChart",  "Ruler", "Sailboat", "Splash", "Stall", "Tank", "Tank2", "Tank3",  "TestPattern", "Tiffany", "Tree", "Truck", "TruckAndAPC",  "TruckAndAPC2", "U2", "Volubilis"} *)

which you can then put this into a Manipulate (or whatever you prefer):

Manipulate[
 ExampleData[{"TestImage", name}],
 {name, names}
 ]

ExampleData Manipulate

$\endgroup$
0
$\begingroup$

This may give you some ideas. Build your interface up as separate components and keep your other code out of your user interface. TrackedSymbols and DynamicWrapper may also be useful at some stage. Take a look at http://www.wolfram.com/broadcast/video.php?v=1718

worddiff[word_, input_] :=Module[{vector = 
{ToCharacterCode[ToLowerCase@ToString@word], 
ToCharacterCode[ToLowerCase@ToString@input]}, diff, abs},
diff = vector[[All, 1 ;; Min@Map[Length, vector]]];
abs = N@MapThread[(Abs[#1 - #2]) &, diff];
Total@MapIndexed[#1/2^First@#2 &, abs]
];

closewordsort[list_, input_] := SortBy[list, worddiff[input, #] &];

namelistinput[Dynamic@value_, Dynamic@namelist_] := 
InputField[Dynamic[value], String,
FieldCompletionFunction -> (closewordsort[
DeleteCases[namelist, _Missing], #] &)];   

imageviewer[Dynamic@list_] := DynamicModule[{name = First@list},
Column[{Dynamic@Length@list, 
namelistinput[Dynamic[name], Dynamic@list],
Dynamic@ExampleData[{"TestImage", name}]}]];


names = ExampleData["TestImage"][[All, 2]];
Column[{Manipulate[names[[1 ;; i]], {i, 4, 10, 1}], 
imageviewer[Dynamic@names]}]
$\endgroup$
  • $\begingroup$ Thank you very much! I am not sure that this is what I am looking for. I am having this list: {"apple", "baby", "back", "bite", "blue", "coffin", "cottage", \ "deep", "deer", "door", "fair", "father", "fell", "find", "forest", \ "found", "front", "glass", "going", "he", "heart", "home", "house", } and I would like to get pictures to these. Could you help in this one? Or your code would work with this? :) Thank you in advance!!! $\endgroup$ – csf Nov 20 '17 at 10:07

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.