MathGroup Archive 2012

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

Search the Archive

Re: Input cells destroy Grids?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124809] Re: Input cells destroy Grids?
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Wed, 8 Feb 2012 05:26:59 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Reply-to: jfultz at wolfram.com

The Grid wasn't ignored.  If you scroll over, you'll see that there is a second 
column, which is not very wide because it doesn't need to be.  The issue has
nothing to do with Grid.  IT has to do with InputField which, by default, sets 
its width in "ems", which is a unit relative to the font size.  I.e., it's 
approximately wide enough to type 20 "m" characters into the field.  Since the 
measurement is relative to the font size, you made the input field much bigger 
when you made its font bigger.

You can try, for example, replacing the InputField with:

InputField[MatrixForm[matrix], FieldSize -> {{4, 20}, {1, Infinity}}]

which sets the width to a range which will be 4 ems at the minimum and 20 ems at the maximum, depending upon the width of the contents of the InputField. I.e., 
as you type more, the InputField grows until it reaches a maximum of 20 ems.

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.


On Tue, 7 Feb 2012 04:03:06 -0500 (EST), Mark Green wrote:
> 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... at 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





  • Prev by Date: Re: importing series of file with the same extension
  • Next by Date: Re: Getting stuck with finding an elegant solution without global variables
  • Previous by thread: Re: Input cells destroy Grids?
  • Next by thread: Re: Input cells destroy Grids?