MathGroup Archive 2008

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

Search the Archive

Re: Variable amount of Buttons in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92776] Re: Variable amount of Buttons in Mathematica
  • From: "sjoerd.c.devries at gmail.com" <sjoerd.c.devries at gmail.com>
  • Date: Mon, 13 Oct 2008 06:17:28 -0400 (EDT)
  • References: <gcscrf$8l3$1@smc.vnet.net>

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