Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8274 > unrolled thread

Input cells destroy Grids?

Started byMark Green <p0073857@brookes.ac.uk>
First post2012-02-01 08:51 +0000
Last post2012-02-11 20:48 +0000
Articles 4 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Input cells destroy Grids? Mark Green <p0073857@brookes.ac.uk> - 2012-02-01 08:51 +0000
    Re: Input cells destroy Grids? A Retey <awnl@gmx-topmail.de> - 2012-02-02 10:04 +0000
      Re: Input cells destroy Grids? Mark Green <p0073857@brookes.ac.uk> - 2012-02-07 09:05 +0000
        Re: Input cells destroy Grids? A Retey <awnl@gmx-topmail.de> - 2012-02-11 20:48 +0000

#8274 — Input cells destroy Grids?

FromMark Green <p0073857@brookes.ac.uk>
Date2012-02-01 08:51 +0000
SubjectInput cells destroy Grids?
Message-ID<jgaufa$esh$1@smc.vnet.net>
I'm trying to make a slide which will allow students to insert arbitrary numbers into a matrix multiplication, and have gotten this:

incel = {1, 2, 3, 4};
matrix = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
Style[Grid[{{MatrixForm[incel, TableDirections -> Row],
    ""}, {InputField[MatrixForm[matrix]], MatrixForm[incel.matrix]}}],
  FontSize -> 40]

It looks fine if I remove the InputField call, but with it in there, the input field takes up the entire width of the notebook, ignoring the fact there's supposed to be a grid cell to the right of it. Also, I have a feeling this won't work in FreeCDF because the input is of a matrix, not a number.

Is there a better way of doing this that inputs only numbers and that fits in a grid?

[toc] | [next] | [standalone]


#8301

FromA Retey <awnl@gmx-topmail.de>
Date2012-02-02 10:04 +0000
Message-ID<jgdn3d$qpg$1@smc.vnet.net>
In reply to#8274
Am 01.02.2012 09:51, schrieb Mark Green:
> I'm trying to make a slide which will allow students to insert arbitrary numbers into a matrix multiplication, and have gotten this:
>
> incel = {1, 2, 3, 4};
> matrix = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
> Style[Grid[{{MatrixForm[incel, TableDirections ->  Row],
>      ""}, {InputField[MatrixForm[matrix]], MatrixForm[incel.matrix]}}],
>    FontSize ->  40]
>
> It looks fine if I remove the InputField call, but with it in there, the input field takes up the entire width of the notebook, ignoring the fact there's supposed to be a grid cell to the right of it. Also, I have a feeling this won't work in FreeCDF because the input is of a matrix, not a number.
>
> Is there a better way of doing this that inputs only numbers and that fits in a grid?

I think this is doing what you want:

matrix = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};

MatrixForm[
  Table[With[{i = i, j = j},
    InputField[Dynamic[matrix[[i, j]]], Number, ImageSize -> 50]], {i, 
4}, {j, 4}]]

If you want, you can use  Appearance -> None for the InputFields which 
makes the result look like what you had. On the other hand I think that 
it usually is best to avoid overdressed user interface but instead stick 
with conventions for guis so everyone will understand at first glance 
how they work...

hth,

albert

[toc] | [prev] | [next] | [standalone]


#8367

FromMark Green <p0073857@brookes.ac.uk>
Date2012-02-07 09:05 +0000
Message-ID<jgqpgi$muj$1@smc.vnet.net>
In reply to#8301
That's perfect, exactly what I wanted - thanks very much!

I would like to know if there's any reason why the Grid was ignored,
though - is it a Mathematica bug or am I combining things incorrectly?


On Feb 2, 10:04 am, A Retey <a...@gmx-topmail.de> wrote:
> Am 01.02.2012 09:51, schrieb Mark Green:
>
> > I'm trying to make a slide which will allow students to insert arbitrary numbers into a matrix multiplication, and have gotten this:
>
> > incel = {1, 2, 3, 4};
> > matrix = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
> > Style[Grid[{{MatrixForm[incel, TableDirections ->  Row],
> >      ""}, {InputField[MatrixForm[matrix]], MatrixForm[incel.matrix]}}],
> >    FontSize ->  40]
>
> > It looks fine if I remove the InputField call, but with it in there, the input field takes up the entire width of the notebook, ignoring the fact there's supposed to be a grid cell to the right of it. Also, I have a feeling this won't work in FreeCDF because the input is of a matrix, not a number.
>
> > Is there a better way of doing this that inputs only numbers and that fits in a grid?
>
> I think this is doing what you want:
>
> matrix = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
>
> MatrixForm[
>   Table[With[{i = i, j = j},
>     InputField[Dynamic[matrix[[i, j]]], Number, ImageSize -> 50]], {i,
> 4}, {j, 4}]]
>
> If you want, you can use  Appearance -> None for the InputFields which
> makes the result look like what you had. On the other hand I think that
> it usually is best to avoid overdressed user interface but instead stick
> with conventions for guis so everyone will understand at first glance
> how they work...
>
> hth,
>
> albert

[toc] | [prev] | [next] | [standalone]


#8478

FromA Retey <awnl@gmx-topmail.de>
Date2012-02-11 20:48 +0000
Message-ID<jh6k7g$jrr$1@smc.vnet.net>
In reply to#8367
Hi,

>> incel = {1, 2, 3, 4};
>> matrix = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
>> Style[Grid[{{MatrixForm[incel, TableDirections -> Row],
>>     ""}, {InputField[MatrixForm[matrix]], MatrixForm[incel.matrix]}}],
>>   FontSize -> 40]

> I would like to know if there's any reason why the Grid was ignored,
> though - is it a Mathematica bug or am I combining things incorrectly?

I think the problem with the above code is just that the InputField will 
be huge (especially its width) for FontSize 40, if I execute the above 
I'll just see the leftmost columns of the Grid, but if I scroll to the 
right I will see the end of the InputField and then the right column 
containing MatrixForm[incel.matrix]. Would that be the same on your 
machine? I'd  try to use a smaller font size just to see whether it works.

hth,

albert



[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web