MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Variable amount of Buttons in Mathematica


It can be done with:

array = {1, 2, 3, 4, 5};
Row[Table[
  With[{n = n},
   Button[array[[n]], Print[n], ImageSize -> {50, 50}]], {n, 1,
   Length[array], 1}]]

This uses the somewhate puzzling With[{n = n} construction, which
replaces every occurance of the *variable* n (which doesn't make sense
after the Table command has finished) with the succesive *values* it
had during the table execution.

Cheers -- Sjoerd


  • Prev by Date: Re: Re: Overlapping binning of differences of
  • Next by Date: Re: Executing external notebook
  • Previous by thread: Variable amount of Buttons in Mathematica
  • Next by thread: Re: Variable amount of Buttons in Mathematica